Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help in analysing a Cobol DB2 program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
V K R A S Srinivas

New User


Joined: 02 Jan 2007
Posts: 9
Location: Hyderabad

PostPosted: Fri Nov 07, 2008 12:40 pm    Post subject: Need help in analysing a Cobol DB2 program
Reply with quote

Hi !

I am analysing a cobol db2 program and need your hlep regarding the same.
Here is what I have in the program.

Code:

EXEC SQL                                                 
   FETCH NEXT ROWSET LOCATION_CSR FOR :WS-LIT-FINAL ROWS
   INTO   :WS-LOCHIER-LOC-CDE1                           
END-EXEC.                                               

PERFORM B2010-GET-DIAGNOSTICS-PARA THRU B2010-EXIT         
                                                           
EVALUATE SQLCODE                                           
    WHEN SQLCODE-SUCCESSFUL                               
         PERFORM B3000-CLOSE-LOCATION-CSR  THRU  B3000-EXIT
         MOVE ROW-COUNT                    TO   WS-LIT-FINA
         ........................




B2010-GET-DIAGNOSTICS-PARA.                             
                                                         
     EXEC SQL                                           
         GET DIAGNOSTICS                                 
           :ROW-COUNT = ROW_COUNT, :NUM-CONDNS = NUMBER 
     END-EXEC.                                           
     EVALUATE SQLCODE                                   
         WHEN SQLCODE-SUCCESSFUL                         
              CONTINUE                                   
         WHEN SQLCODE-ROW-NOT-FOUND                     
              CONTINUE                                   
         WHEN OTHER                                     
              MOVE 'ERROR WHILE GET DIAGNOSTICS'         
                                  TO WS-ERR-ACTION       
         .............................................



My question here is.
According to my understanding, Evaluate SQLCODE should immediately follow the SQL stmt. Here in the code,
there is a PERFORM Stmt btw the FETCH sql stmt and EVALUATE SQLCODE. So here it looks like, the SQLCODE returned from the GET DIAGNOSTICS is being Evaluated twice (in the B2010-GET-DIAGNOSTICS-PARA & after the PERFORM B2010-GET-DIAGNOSTICS-PARA THRU B2010-EXIT). Please let me know if my understanding is correct or not.

Also, if the FETCH stmt is not successful, is there a chance of GET DIAGNOSTICS to be successful.

Thank you in advance,
Srinivas Vaddadi
Back to top
View user's profile Send private message

hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Nov 07, 2008 4:36 pm    Post subject: Reply to: Need help in analysing a Cobol DB2 program
Reply with quote

Hi Srinivas,

You are correct!!

The sql code returned from GET DIAGNOSTICS statement is being evaluated twice. This needs to be fixed.

Thanks,
-Kapil.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Fri Nov 07, 2008 5:50 pm    Post subject:
Reply with quote

In the 2nd SQL CODE check, Row Count, which is retrieved form the GET DIAGNOSTICS statement, is moved into some other variable. So you have to check the statements after
Code:

MOVE ROW-COUNT                    TO   WS-LIT-FINA


And you have to add SQLCODE check after FETCH statement also.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 3 Mon May 29, 2017 8:10 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us