Advertisement

07.10.2003 at 07:51AM PDT, ID: 20674454
[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!

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

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;
/
Start your free trial to view this solution
Question Stats
Zone: Database
Question Asked By: shaynegw
Solution Provided By: Uncertified_DBA
Participating Experts: 5
Solution Grade: B
Views: 452
Translate:
Loading Advertisement...
07.10.2003 at 08:41AM PDT, ID: 8893990

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.10.2003 at 08:43AM PDT, ID: 8894013

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.10.2003 at 09:13AM PDT, ID: 8894294

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.10.2003 at 09:24AM PDT, ID: 8894376

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.10.2003 at 09:50AM PDT, ID: 8894610

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.11.2003 at 03:26AM PDT, ID: 8900904

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.14.2003 at 02:52AM PDT, ID: 8915704

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.14.2003 at 08:50AM PDT, ID: 8918151

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2003 at 01:00PM PDT, ID: 9243403

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2003 at 02:47PM PDT, ID: 9244011

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29