Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / December 2007

Tip: Looking for answers? Try searching our database.

Parsing resultset from procedure to procedure to caller

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nils - 08 Dec 2007 11:15 GMT
I would like to have the SPinner() to return the cursor (cc) to
SPouter, which returns it to caller (client).

My simple procedures is as follows:

CREATE PROCEDURE SPinner ()
 LANGUAGE SQL
 result sets 1
BEGIN
 declare cc cursor with return TO CALLER for
 select mytable.col1, mytable.col2 from mytable;
 open cc;
END

CREATE PROCEDURE SPouter ()
 LANGUAGE SQL
 result sets 1
BEGIN
 call SPinner();
END

... but this doesn't get the cc-cursor into SPouter(). I've then been
looking at "allocate cursor" in conjunction with "associate" like
this:

CREATE PROCEDURE SPouter ()
   LANGUAGE SQL
   result sets 1
BEGIN
   DECLARE loc RESULT_SET_LOCATOR VARYING;
   call SPinner();
   ASSOCIATE RESULT SET LOCATOR(loc) WITH PROCEDURE SPinner;
   ALLOCATE C1 CURSOR FOR RESULT SET loc;
   open C1;
END

... but it returns SQLSTATE: 51030 upon runtime.
Serge Rielau - 08 Dec 2007 14:43 GMT
> I would like to have the SPinner() to return the cursor (cc) to
> SPouter, which returns it to caller (client).
[quoted text clipped - 33 lines]
>
> ... but it returns SQLSTATE: 51030 upon runtime.
You have to consume the cursor in the caller.
In your case I think using a temporary table to park the result set
would be the best option.

Cheers
Serge

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.