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 > Count values returned from stored procedure?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-23-09, 15:53
skydiverMN skydiverMN is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
Question Count values returned from stored procedure?

I have a DB2 stored procedure that returns a dataset (opened and returned cursor) of a buncha rows. It's now become necessary to determine the number of rows returned. Is there an easy way to handle this?

My logic here is invalid, but hopefully you'll get the point that I'm trying to accomplish:

select count(*) from DBName.STOREPROCEDURENAME;

Can it be that simple? Do you have any examples?
Thoughts?

Thanks!
SkydiverMN
Reply With Quote
  #2 (permalink)  
Old 07-23-09, 16:32
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
You have to create the SP with integer output parameter. Could be in-out, too.
Then find the number of rows inside of the SP, before open cursor to return.
Put this number in the output parameter, then you can continue with your SP in the regular way.

Lenny K.
Reply With Quote
  #3 (permalink)  
Old 07-23-09, 16:50
skydiverMN skydiverMN is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
yep, thanks.

I don't know what I was thinking. I added an output param, and simply set this value based on my conditions during the processing. Works pretty slick. Thanks!
Reply With Quote
  #4 (permalink)  
Old 07-23-09, 17:40
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
No problem !

Lenny
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