Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL and recursive calls

PL/SQL and recursive calls

From: Sir John Patrick Ryan <ryanj_at_iria.mines.u-nancy.fr>
Date: 1997/07/02
Message-ID: <slrn5rko24.8hi.ryanj@iria.mines.u-nancy.fr>#1/1

DESCRIPTION:
Imagine the following problem :
You have a source tree A and a destination tree B Trees are represented by a simple table :

   Name VARCHAR2(10) : identification of a leaf    Rec_level NUMBER(8) : indication of level of recursivity    Parent VARCHAR2(10) : parent of the current name

The idea of the process is to synchronise destination tree to source tree. This is done by going through the tree recursively and creating/deleting leafs in the destination table where needed.

I've written a PL/SQL stored procedure to do so but I am facing a problem of cursor variable which I don't understand

When I come back to the first level after a recursive call, the cursor state-variable GetNextB%FOUND has changed from FALSE to NULL although I am in a middle of fetching.

QUESTION:
Do you think its a bug? (how do I report it to Oracle) Do you think I missuse the variable cursor%FOUND ? Do you think PL/SQL does not support Recursive calls ?

I have a complete file with source, test data and output if it helps i can send it by mail.
Please if you answer in this group, send me a mail to stb_at_sophia.sema.fr

/-----------------------------------------------------

| Stephane TABARY SEMA GROUP TELECOM
| Ingenieur Sophia-Antipolis, France (06)
| stb_at_sophia.sema.fr

algorithm used:
...
procedure AdvanceTree(curParentA, CurParentB) is cursor GetNextA(pParentA)
select name
from tableA
where parent=pParentA
order by name;

cursor GetNextiB(pParentB)
select name
from tableB
where parent=pParentB
order by name;

begin
open GetNextA(curParentA);
open GetNextB(curParentB);
fetch GetNextA ...
fetch GetNextB ...

loop
if (A-NotFound and B-NotFound)
  exit
elsif ((A-NF and B-F) or (A-F and B-F and nameA > nameB))   delete leaf and all descendant in B
  fetch GetNextB
elsif ((A-F and B-NF) or (A-F and B-F and nameA < nameB))   create leaf in B
  AdvanceTree(currentA, currentA)
  fetch GetNextA
elsif (A-F and B-F and nameA = nameB)
  AdvanceTree(currentA, currentB)
  fetch GetNextA
  fetch GetNextB
end if
end loop
end Received on Wed Jul 02 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US