IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need help in analysing a Cobol DB2 program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 355
Location: New York

PostPosted: Fri Nov 07, 2008 5:50 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top