View previous topic :: View next topic
|
Author |
Message |
V K R A S Srinivas
New User
Joined: 02 Jan 2007 Posts: 9 Location: Hyderabad
|
|
|
|
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 |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
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 |
|
|
|