View previous topic :: View next topic |
Author |
Message |
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Thu Jan 26, 2006 10:32 am Post subject: Returning Error from a Stored Procedure w/External COBOL |
|
|
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 |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Thu Jan 26, 2006 3:58 pm Post subject: |
|
|
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 |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Thu Jan 26, 2006 4:07 pm Post subject: |
|
|
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 |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Mon Jan 30, 2006 9:48 am Post subject: |
|
|
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 |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Mon Jan 30, 2006 10:45 am Post subject: |
|
|
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 |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Tue Jan 31, 2006 9:50 am Post subject: |
|
|
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 |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Fri Feb 03, 2006 7:08 pm Post subject: |
|
|
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 |
|
|
|
|