dbTalk Databases Forums  

Re: Recursive Cursors

comp.databases comp.databases


Discuss Re: Recursive Cursors in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tokunaga T.
 
Posts: n/a

Default Re: Recursive Cursors - 07-23-2003 , 08:34 AM






dammad (AT) mighty (DOT) co.za (DammaD) wrote in message
Quote:
..... I have a list
of items with children who have childern, etc, to a variable length,
and I need a tree structure to be displayed. Using a cursor I get a
list of top level items, then going through each record, I check for
children for that item, and if a child exists, I call the sp, and the
process continues.
You can use recursive query rather than recursive sp or cursor.
Many DBMS support recursive query. For example, DB2 UDB support it
with common table expression(after WITH keyword), Oracle support it
with CONNECT BY clause, etc.


Reply With Quote
  #2  
Old   
Jonathan Leffler
 
Posts: n/a

Default Re: Recursive Cursors - 07-26-2003 , 01:41 AM






DammaD wrote:

Quote:
Hi all

Is there anyway to use a cursor in a sp that gets called recursivly?
If I create a sp that calls itself and it has a cursor in it, it
displays the error, "cursor already exists".(obviously) I have a list
of items with children who have childern, etc, to a variable length,
and I need a tree structure to be displayed. Using a cursor I get a
list of top level items, then going through each record, I check for
children for that item, and if a child exists, I call the sp, and the
process continues. But of course it declares a cursor with the same
name in the sp and it gives error. I don't know how many cursors I
will need so it must be dynamic. So I thought I'd just pitch it to you
guys, as I think it is impossible.

Depends on your DBMS. IBM/Informix IDS allows it.

--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler (AT) earthlink (DOT) net, jleffler (AT) us (DOT) ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/



Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.