Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010
    Posts
    32

    Unanswered: SQL0413N Overflow occurred during numeric data type conversion.

    Why do it shows me the numeric dat type conversion error when i use the same data type for all the values.

    If i remove the insert statement it works fine for me .


    Code:
    create procedure test  (in v_depno varchar(3), out v_totalsalary decimal(9,2))
    begin
      declare SQLCODE  integer     default 0;
      declare i        decimal(9,2);
      declare mycur cursor for
          select SALARY
          from EMPLOYEE
          where WORKDEPT = v_depno;
    
      set v_totalsalary = 0;
      open mycur;
      fetch mycur into i;
      while SQLCODE <> 100
       do
         set v_totalsalary = v_totalsalary + i;
         fetch mycur into i;
    insert into test values (i);
      end while;
      close mycur;
    end!
    Code:
    create table test (sal decimal(9,2))
    Please let me know what's causing the issue .

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Your "while SQLCODE" is testing on the result of the INSERT, not of the FETCH.
    So move the INSERT up one line.
    (And replace the WHILE test by "WHILE SQLCODE = 0".)
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •