Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us