Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recursive Stored Procedure

Status
Not open for further replies.

sefafo

Programmer
Aug 28, 2003
36
0
0
CO
Hello ...!

Any body knws how to create a recursive stored procedure??

<b>Thaks to all</b>

 
Take a look there:


If you don't understand something in that example, post there your question.

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
actually it did not help me...What I want is to use a stored procedure <b>RECURSIVAMENTE</B>i, like a Function in a programming language..

 
Umm to create a recursive stored procedure you just have the SP call itself from with inside itself

The only issues you have to do with is that you'll get warnings from the parser that the SP doesn't exsiste when you first create the SP and the nesting level as you can only go 32 levels deep in stored procs.


Hope I've been helpful,
Wayne Francis

If you want to get the best response to a question, please check out FAQ222-2244 first
 
sefafo, in SQL you have to look on RECURSIVE programing by another way.

In other languages, like C++ when you call some function recursive, it stores all variables into stack and after execution of function it pop data from stack and you have not limit on size of that stack ( expect memory or some special setting, but I am sure it is not only 32 leveles )

In SQL you have to program your own stack by using temporary table and go throught loop as in that example I post link to. And in that case, there is great command GOTO label which can be used to control where to return after one 'nested' loop if you need recursive calls from more than one place ( you simply store return_label into stack together with other variables you want, and at the end, you pop up them and do GOTO return_label )

Post there in concrete what you are want to do and we can show same example.

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top