Page 1 of 1

SQL Code 00000050J NEED HELP

PostPosted: Wed Apr 14, 2010 12:27 pm
by swathi.nelaturu
hI FRIENDS,
I am Swathi.
I am the begginer in DB2.
I got a doubt.
After select query i am getting the sql code 00000050J
I am not understanding the meaning for that.

My code is

 ID DIVISION.                       
 PROGRAM-ID. PG1.                   
 ENVIRONMENT DIVISION.               
 INPUT-OUTPUT SECTION.               
 DATA DIVISION.                     
 WORKING-STORAGE SECTION.           
     EXEC SQL                       
        INCLUDE SQLCA               
     END-EXEC.                       
     EXEC SQL                       
        INCLUDE USR                 
     END-EXEC.                       
     EXEC SQL                       
        DECLARE QD CURSOR WITH HOLD 
        FOR                         
        SELECT PWD FROM USR7         
        WHERE UID = :HV-UID
        FOR UPDATE OF PWD               
     END-EXEC.                         
 PROCEDURE DIVISION.                   
     MOVE 'SWATHI' TO HV-UID.           
     EXEC SQL                           
      OPEN QD                           
     END-EXEC.                         
     EXEC SQL                           
      FETCH QD INTO :HV-PWD             
     END-EXEC.                         
     EVALUATE SQLCODE                   
       WHEN 0                           
         MOVE 'RADHIKA' TO HV-PWD       
         EXEC SQL                       
           UPDATE USR7 SET PWD = :HV-PWD
           WHERE CURRENT OF QD         
         END-EXEC                       
      WHEN OTHER       
        DISPLAY SQLCODE
    END-EVALUATE.       
    EXEC SQL           
      CLOSE QD         
    END-EXEC.           
    STOP RUN.         


Can any one plzz help meee...........

Thanks in Advance,
Swathi.

Re: SQL Code 00000050J NEED HELP

PostPosted: Wed Apr 14, 2010 6:16 pm
by uday123
Hi Swathi,

Welcome to the forum..
Please confirm if this is SQL code of 501 or SQL CODE 50J.

If its sql code 501 , then you are trying to fetch the rows when the cursor is closed.
Cursor needs to be opened , before the rows are fetched.


Hope this helps ..

Regards
Uday

Re: SQL Code 00000050J NEED HELP

PostPosted: Wed Apr 14, 2010 11:32 pm
by dick scherrer
Hello,

50J is a -501. . .

Re: SQL Code 00000050J NEED HELP

PostPosted: Wed Apr 14, 2010 11:37 pm
by dick scherrer
Hello and welcome to the forum,

Suggest you practice with the "Code" tag (which will preserve alignment and improve readability) - your pgm has been "Code'd"..

If you only learn one thing this week, you need to look at the sql return code after EVERY EXEC SQL statement. I suspect the cursor open failed. . .