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 > Stored procedure calling sp, filtering returned 'child' data back to calling entity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-22-09, 12:46
skydiverMN skydiverMN is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
Question Stored procedure calling sp, filtering returned 'child' data back to calling entity

Okay, so I'm on DB2 v8.x and I'm trying to have a stored procedure call a stored procedure. This isn't a problem in itself, but what I'd like to do is have the parent then return a filtered set of data from what was returned from the child sp. Need more explanation?

I'm using .NET to call the parent DB2 sp.
1) Parent sp calls child sp to pull some set of data. The BIG pull of everything
2) Child returns big data set back to parent.
3) Within parent determine which column is needed (from input param) and take only that needed column of child's BIG data and return that back to the calling entity with return.

So I was thinking about a temporary table in the parent that will house the data. Problem is, you can't do this (simplified without CREATE TABLE stmt, etc):

set tablename = call childsproc();

How can I set the temporary table to house the child BIG pull? From here, I'd think I could loop through inserting records into another table, then use a cursor to select this data and return it. Get where I'm coming from?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 10-22-09, 13:36
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
First, I think it is not a good idea to get all the data and then do some post-processing (filtering) on it. Instead, you should try to pass the filtering predicates and projects right to the "child sp". That will be faster and easier, too.

As for the actual question: you can declare a temporary table, associate a cursor with the result set returned by "child sp", fetch from the cursor and insert the fetched data into the temp table.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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