If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Can somebody tell me why....?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-21-05, 09:21
database_abuser database_abuser is offline
Registered User
 
Join Date: Dec 2004
Location: Frankfurt
Posts: 26
Can somebody tell me why....?

Hi all,

can somebody tell me why the very last operation in a stored procedure (Z/0S, DB2 V7.1, Cobol LE370 stored procedure) has to be the DECLARE CURSOR?

As a conscientious (sp?) programmer, I always check the SQL code after any SQL operation. However, if I do this AFTER the declare cursor with return, the result set is not available to the calling program. WHY? I once lost a couple of hours trying to figure out where my result set went. And I haven't found anything particularly enlightening on this subject anywhere.

This is purely for my curiosity - if someone happens to know the why, I'd be interested.

Thanx in advance

L8r, eh?
Ralph
Reply With Quote
  #2 (permalink)  
Old 01-21-05, 09:36
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Just to clarify, I think you mean that the OPEN cursor must be in the last SQL statement, not the DECLARE cursor. But I don't know the reason for it.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 01-23-05, 18:51
jacampbell jacampbell is offline
Registered User
 
Join Date: Jan 2005
Posts: 191
(I too presume you mean OPEN) I've written SPs in this environment where I've checked the sqlcode after the open. And, since checking the sqlcode does not involve any interaction with DB2, I would be surprised if it did.

The only thing that comes to mind is that you are somehow closing the cursor - either a commit/rollback without WITH HOLD or an explicit close.

James Campbell
Reply With Quote
  #4 (permalink)  
Old 01-24-05, 02:07
database_abuser database_abuser is offline
Registered User
 
Join Date: Dec 2004
Location: Frankfurt
Posts: 26
Hi again,

by 'last operation' I meant any operation, be it exec sql or otherwise. It seems there must be a goback immediately after the open cursor.

yup, after the OPEN CURSOR I can't even check the sqlcode or my result set seems to disappear.

In the calling program, after the exec sql call xxxx, I check the sqlcode to see if it is 466, when it is, then I do an associate locators followed by an allocate cursor using the locator.

l8r, eh,
Ralph
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On