View previous topic :: View next topic |
Author |
Message |
pradeepg Beginner

Joined: 06 Jan 2003 Posts: 25 Topics: 12 Location: Columbus, OH
|
Posted: Mon Aug 22, 2005 3:18 pm Post subject: RETURN-CODE reserve word - How does it work |
|
|
Hello List,
Is the reserve word RETURN-CODE would be set after each COBOL or DB2 instruction has been executed.
Suppose my code is like this
Move 08 TO RETURN-CODE
CLOSE OTFILE
**** What does RETURN-CODE will contain at this point ???
MOVE 12 TO RETURN-CODE
EXEC SQL
COMMIT
END-EXEC
**** What does RETURN-CODE will contain at this point ???
Appreciate your responses.
- Pradeep |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Mon Aug 22, 2005 4:37 pm Post subject: |
|
|
pradeepg,
It does not matter how many times you move values to the return-code. The last value moved before your program completion will be the condition code of that step.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
pradeepg Beginner

Joined: 06 Jan 2003 Posts: 25 Topics: 12 Location: Columbus, OH
|
Posted: Tue Aug 23, 2005 1:54 pm Post subject: |
|
|
So that means any other COBOL statement would have no effect on this reserve word other than execlusively moving some value into it.
One of our colleague is saying before executing an SQL statement it has the value what ever he had moved, but after succesful execution of the SQL the value in the RETURN-CODE has changed to 0. So wondering any other statement's succesful execution would cause this value to become 0.
Thanks,
Pradeep |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Aug 23, 2005 2:05 pm Post subject: |
|
|
Quote: |
One of our colleague is saying before executing an SQL statement it has the value what ever he had moved, but after succesful execution of the SQL the value in the RETURN-CODE has changed to 0. So wondering any other statement's succesful execution would cause this value to become 0. |
pradeep,
SQLCODE and RETURN-CODE have no relation. Return-code is a cobol variable and SQLCODE is a DB2 variable. The return-code values remain unchanged after the successful execuetion of a sql stmt unless you are moving a new value after the successful execuetion of the sql.
Hope this helps..
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Tue Aug 23, 2005 11:17 pm Post subject: |
|
|
pradeepq,
Just check with your colleague if he is having a sub-program to execute the SQL statement. In that case, the sub-program would have manipulated the value in RETURN-CODE.
Thanks,
Phantom |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed Aug 24, 2005 7:31 am Post subject: |
|
|
I tried it. I set the return code to 1 and executed an SQL call. The return code was set to 0 after the call. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Aug 24, 2005 7:47 am Post subject: |
|
|
Quote: |
I tried it. I set the return code to 1 and executed an SQL call. The return code was set to 0 after the call.
|
Bithead,
When a COBOL program contains SQL statements ,the pre-compiler converts the EXEC SQL statements to CALLS to DSNHADDR which acts as a sub-routine which resets the return-code. If the calling program is a COBOL program, the RETURN-CODE special register in the calling program is set to the value of the RETURN-CODE special register in the called program. If you have user-written condition handler, your return-code would have the value which you moved prior to the sql call.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed Aug 24, 2005 8:13 am Post subject: |
|
|
But it does show that the RETURN CODE is modified. |
|
Back to top |
|
 |
pradeepg Beginner

Joined: 06 Jan 2003 Posts: 25 Topics: 12 Location: Columbus, OH
|
Posted: Wed Aug 24, 2005 1:38 pm Post subject: |
|
|
I tested myself and confirmed that after SQL statement execution, the RETURN-CODE value would change to ZERO. I think the reason has been explained by Kolusu. It is also documented in COBOL manual.
Because SQL statement converts to CALL statement so the subroutine is setting this value back to zero.
- Pradeep |
|
Back to top |
|
 |
|
|