MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RETURN-CODE reserve word - How does it work

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
pradeepg
Beginner


Joined: 06 Jan 2003
Posts: 25
Topics: 12
Location: Columbus, OH

PostPosted: Mon Aug 22, 2005 3:18 pm    Post subject: RETURN-CODE reserve word - How does it work Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Aug 22, 2005 4:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
pradeepg
Beginner


Joined: 06 Jan 2003
Posts: 25
Topics: 12
Location: Columbus, OH

PostPosted: Tue Aug 23, 2005 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 23, 2005 2:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Aug 23, 2005 11:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Wed Aug 24, 2005 7:31 am    Post subject: Reply with 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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 24, 2005 7:47 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Wed Aug 24, 2005 8:13 am    Post subject: Reply with quote

But it does show that the RETURN CODE is modified.
Back to top
View user's profile Send private message
pradeepg
Beginner


Joined: 06 Jan 2003
Posts: 25
Topics: 12
Location: Columbus, OH

PostPosted: Wed Aug 24, 2005 1:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group