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 

Returning Error from a Stored Procedure w/External COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Thu Jan 26, 2006 10:32 am    Post subject: Returning Error from a Stored Procedure w/External COBOL Reply with quote

Is it possible to return an error for an SQL operation? Let me clarify.
1. The client calls the procedure
2. Procedure calls COBOL program for SQL
3. COBOL receives a non-zero SQL return code
4 Returns to procedure with a Zero return
5 Returns to client, everything seens to be OK

I can code a variable and return the proper SQL codes along with a very descriptive error. What I'm wondering is it possible to throw the error without a variable? Also without hard coding any error.
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Thu Jan 26, 2006 3:58 pm    Post subject: Reply with quote

NASCAR9,

Call DSNTIAR from the program that runs the SQL to get the proper error message and pass on both the message and the SQLCODE all the way back to the client.
You don't have to hard-code any error messages but you have to define variables to hold the SQLCODE and the message in the I-O area of all your procedures.

HTH...Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Thu Jan 26, 2006 4:07 pm    Post subject: Reply with quote

Manas Biswal,
I have already done what you suggested. What I would like to do is have Db2 pass the error to the client without a varible. Seems in the .Net world there is an Error trapping routine that would capture and handle an error this way.

If the VB.Net app does a direct call to DB2 without a stored procedure the error is passed back directly. I would like the stored procedures to do this.
I may be asking too much, not sure.
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Jan 30, 2006 9:48 am    Post subject: Reply with quote

NASCAR9,

Quote:
What I would like to do is have Db2 pass the error to the client without a varible.


I am not familiar with the .Net world but logically speaking, there has to be a variable. Either it has to be a variable in the application program defined by you or it has to be a control program variable that is included in your program, while translating/compiling/link-editing. (For example - SQLCODE).
Whenever a client program calls a stored procedure running on DB2 (SPAS or WLM), there is sort of a modular independence between the client program and the stored procedure. That is also the way it is intended to be. Hence, you have to define variables(or a cursor) to pass back any information between the stored procedure and the client program. (Unless your client program provides control variables for capturing and passing back error messages).

HTH...Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Mon Jan 30, 2006 10:45 am    Post subject: Reply with quote

Manas Biswal,
Thanks for your interest and help. I have researched and researched and the answer seems to be variables.
The doc I'm using is 'DB2 for z/OS Stored Procedures: Through the Call and Beyond'.
Thanks Again!
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Jan 31, 2006 9:50 am    Post subject: Reply with quote

NASCAR9,

Quote:

The doc I'm using is 'DB2 for z/OS Stored Procedures: Through the Call and Beyond'.


Thats the best redbook on the topic....Good Luck...

Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Feb 03, 2006 7:08 pm    Post subject: Reply with quote

I have an update. After reading 'DB2 for z/OS Stored Procedures: Through the Call and Beyond' cover to cover, I created a procedure in DB2 Development Center using SQL. This procedure is created on the client and pushed up to the mainframe. From the mainframe it is converted to "C" source code, compiled, and then bound to the plan the Collection is pointing to. To make a long story short, it returns an error to the client without requiring a variable to be defined to the stored procedure.
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database 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