[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

ORA-06502: PL/SQL: numeric or value error: character to number conversion error /w ORA-06512 error

Asked by shaynegw in Oracle 3rd Party Tools

Tags: error, numeric, value, number, conversion

Hi

I have a situation where the attached script works fine with different SQL*Plus clients (8 and 9), on a variety of PCs (all W2K), with a variety of Oracle network databases (AIX and W2K: 7.3, 8.1.7, 9.0.2), but it will not work on one client machine.

The machine is a W2K PC running SQL*Plus 9.0.1.3.0 against an AIX Oracle 8.1.7 database. Once again, I can run the same script from another W2K machine, using the same SQL*Plus, against the same Oracle target, with the same Oracle login, so I am confident that the problem is related to a configuration issue on the machine where the script will not work.

The error I get on that machine is:
"ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 40"

The suspect lines seem to be:
...
subtotal := to_number(c1_rec.pamount) + to_number(c1_rec.paint);
insert into pencash_calc
    values(key_id, pdate, null, c1_rec.pmemo, null, c1_rec.payto, subtotal);
...

subtotal is a varchar with numerical assignments, and subtotal := to_char(to_number(c1_rec.pamount) + to_number(c1_rec.paint)) makes no difference, but again this script works elsewhere so I am not sure why this one machine can't run it.

If we comment out the subtotal := line and replace the field insertion with a null, the script works on the suspect machine.

I have also compared the SQL*Plus environment options, and tnsnames.ora and sqlnet.ora files between the suspect machine and a working one, and but I could find no significant differences.

Any ideas on what to look for on the suspect machine or what the underlying problem is?

Thanks and take care,
Shayne

script:
/*
SQL> desc pencash
 Name                            Null?    Type
 ------------------------------- -------- ----
 KEY                                      VARCHAR2(14)
 FDATE                                    DATE
 PDATE                                    DATE
 PAMOUNT                                  VARCHAR2(40)
 PAINT                                    VARCHAR2(40)
 PAYTO                                    VARCHAR2(40)
 PMEMO                                    VARCHAR2(40)
 PCHNO                                    VARCHAR2(8)
*/
/*
SQL> desc pencash_calc;
 Name                            Null?    Type
 ------------------------------- -------- ----
 KEY_ID                                   VARCHAR2(40)
 PDATE                                    DATE
 GROSSAMT                                 VARCHAR2(40)
 PMEMO                                    VARCHAR2(50)
 PER_CENT                                 VARCHAR2(40)
 PAYTO                                    VARCHAR2(40)
 SUBTOTAL                                 VARCHAR2(80)
*/

truncate table pencash_calc;

DECLARE

   CURSOR c1 IS
      SELECT
       p.key,
      p.pdate,
        p.pmemo,
      p.payto,
      p.pamount,
        p.paint
        FROM pencash p      
--      group by p.key, p.date  
        ORDER BY p.key;


  c1_rec                 c1%ROWTYPE;
  w_sql_code             number := 0;
  w_sql_mssg             varchar2(79);
  gross_amt             varchar2(40) := 0;
  Key_id             varchar2(10);
  pdate                   date;
  temp_Key             varchar2(10);
  temp_pdate             date;
  temp_pmemo             varchar2(50);
  temp_payto             varchar2(9);
  subtotal             varchar2(80);

BEGIN

  OPEN c1;

  FETCH c1 into c1_rec;
  temp_key := c1_rec.key;
  temp_pdate := c1_rec.pdate;

  LOOP
    EXIT WHEN c1%NOTFOUND;
    key_id := c1_rec.key;
    pdate := c1_rec.pdate;    
    subtotal := to_number(c1_rec.pamount) + to_number(c1_rec.paint);

    /*dbms_output.put_line('key: '||key_id||' pdate: '||pdate||' gross: '|| null||
      ' memo: '||c1_rec.pmemo||' percent: '||null||' payto: '||c1_rec.payto||
      ' subtotal: '||subtotal);*/
    insert into pencash_calc
    values(key_id, pdate, null, c1_rec.pmemo, null, c1_rec.payto, subtotal);

    if pdate = temp_pdate and temp_key = key_id then
          gross_amt := gross_amt + subtotal;
    else
      update pencash_calc
      set grossamt = gross_amt
      where key_id = temp_key
      and pdate = temp_pdate;

          temp_pdate := pdate;
      temp_key := key_id;

      gross_amt := gross_amt + subtotal;
    end if;
    FETCH c1 into c1_rec;
  END LOOP;

   CLOSE c1;

   COMMIT;

   END;
/
[+][-]07/10/03 08:41 AM, ID: 8893990Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/03 08:43 AM, ID: 8894013Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/03 09:13 AM, ID: 8894294Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/10/03 09:24 AM, ID: 8894376Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/03 09:50 AM, ID: 8894610Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/11/03 03:26 AM, ID: 8900904Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/14/03 02:52 AM, ID: 8915704Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Oracle 3rd Party Tools
Tags: error, numeric, value, number, conversion
Sign Up Now!
Solution Provided By: Uncertified_DBA
Participating Experts: 5
Solution Grade: B
 
[+][-]07/14/03 08:50 AM, ID: 8918151Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/28/03 01:00 PM, ID: 9243403Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/28/03 02:47 PM, ID: 9244011Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81