467,189 Members | 1,173 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,189 developers. It's quick & easy.

Calling a nested stored procedure in DB2

Hi,

I have 2 stored procedures A and B. A makes a call to B and B returns a cursor to A. Stored Procedure B executes fine individually. However, when I execute A, I get the following error:

SQLState = 07003
SQLCode = -518

Code snippet for stored procedure B:

DECLARE SampleCursor CURSOR WITH RETURN TO CALLER FOR
SELECT *
FROM TABLE
FETCH FIRST 5 ROWS ONLY;

OPEN SampleCursor

Code snippet for stored procedure A:

DECLARE LOC1 RESULT_SET_LOCATOR VARYING;

CALL B(OUT_SQLCODE, OUT_SQLSTATE, OUT_MESSAGE);

ASSOCIATE RESULT SET LOCATOR (:LOC1) WITH PROCEDURE B;
ALLOCATE CSR1 CURSOR FOR RESULT SET :LOC1;

EXECUTE CSR1 USING LOC1;

Can anyone please help me with this?
Aug 7 '07 #1
  • viewed: 5329
Share:
1 Reply
Do not use the following execute statement. Just fetch that cursor in the stored procedure in order to read the data or get the result set from other applications by calling the stored procedure.

EXECUTE CSR1 USING LOC1; --Not required, as Allocate will open the cursor.
Sep 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Angelina | last post: by
7 posts views Thread by Anthony Robinson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.