472,337 Members | 1,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

Recursive stored proc call

I have a database I have inherited (new job). I am trying to baseline
the code and have done a DB2Look to get the code out of an existing
db. The DB2Look produced a SP with the following form:

Create SP1

(various code)

call sp1()

(various code)
end

This code will not compile because of the procedure is calling itself,
but the procedure does not yet exist so it cannot resolve the code.
Since this is currently in a working database I assume that it got
compiled, somehow. I've not run across this before and am stumped.
Is there some trick to getting a recursive call to compile?

thanks

Jack

Feb 2 '07 #1
3 3072
On Feb 2, 9:20 am, oregon...@yahoo.com wrote:
I have a database I have inherited (new job). I am trying to baseline
the code and have done a DB2Look to get the code out of an existing
db. The DB2Look produced a SP with the following form:

Create SP1

(various code)

call sp1()

(various code)
end

This code will not compile because of the procedure is calling itself,
but the procedure does not yet exist so it cannot resolve the code.
Since this is currently in a working database I assume that it got
compiled, somehow. I've not run across this before and am stumped.
Is there some trick to getting a recursive call to compile?

thanks

Jack
Hi, Jack:

Recursive SQL procedures are possible, but there's one thing you need
to do a little differently--precisely because of what you've bumped up
against--which is to make the call in dynamic SQL. The procession is
like so:

CREATE SP1()
*various and sundry declarations*
DECLARE v_SP_Call VARCHAR(100) DEFAULT 'CALL SP1()';--
*various and sundry code*
EXECUTE IMMEDIATE v_SP_Call;--
*various and sundry code*
END;

As to how it got compiled before, I'm stumped (if not skeptical), but
the way described here will work.

HTH,

--Jeff

Feb 2 '07 #2
On Feb 2, 10:14 am, "jefftyzzer" <jefftyz...@sbcglobal.netwrote:
On Feb 2, 9:20 am, oregon...@yahoo.com wrote:


I have a database I have inherited (new job). I am trying to baseline
the code and have done a DB2Look to get the code out of an existing
db. The DB2Look produced a SP with the following form:
Create SP1
(various code)
call sp1()
(various code)
end
This code will not compile because of the procedure is calling itself,
but the procedure does not yet exist so it cannot resolve the code.
Since this is currently in a working database I assume that it got
compiled, somehow. I've not run across this before and am stumped.
Is there some trick to getting a recursive call to compile?
thanks
Jack

Hi, Jack:

Recursive SQL procedures are possible, but there's one thing you need
to do a little differently--precisely because of what you've bumped up
against--which is to make the call in dynamic SQL. The procession is
like so:

CREATE SP1()
*various and sundry declarations*
DECLARE v_SP_Call VARCHAR(100) DEFAULT 'CALL SP1()';--
*various and sundry code*
EXECUTE IMMEDIATE v_SP_Call;--
*various and sundry code*
END;

As to how it got compiled before, I'm stumped (if not skeptical), but
the way described here will work.

HTH,

--Jeff- Hide quoted text -

- Show quoted text -
May I hasten add, for the benefit of hair-splitters everywhere, that
the "v_SP_Call" variable doesn't necessarily need to be 100. Please
size appropriately for the real name (and possibly fully qualified
path) of the SP.

:-)

--Jeff

Feb 2 '07 #3
I think I did this a long time ago by building a dummy procedure that
didn't have the recursive call as a "seed" to allow the real procedure
to compile.

Phil Sherman
or*******@yahoo.com wrote:
I have a database I have inherited (new job). I am trying to baseline
the code and have done a DB2Look to get the code out of an existing
db. The DB2Look produced a SP with the following form:

Create SP1

(various code)

call sp1()

(various code)
end

This code will not compile because of the procedure is calling itself,
but the procedure does not yet exist so it cannot resolve the code.
Since this is currently in a working database I assume that it got
compiled, somehow. I've not run across this before and am stumped.
Is there some trick to getting a recursive call to compile?

thanks

Jack
Feb 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Song | last post by:
Hi all I am implementing a stored procedure which needs to recursively call itself until specific condition is reached, Could anyone give some...
2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create,...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command,...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data...
3
by: mandible | last post by:
I'm trying to call one stored procedure inside another. I was wondering if this is possible Some ideas I was toying with is putting the first...
0
by: ravindrag | last post by:
Hi, I am getting error SQL1131N during sqlj.install_jar(...). There is no useful message in the diag.log (even with diag level 4). I am giving the...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.