Home » SQL & PL/SQL » SQL & PL/SQL » handling recursive call in pl/sql
handling recursive call in pl/sql [message #354325] Fri, 17 October 2008 13:57 Go to next message
kanis
Messages: 61
Registered: November 2006
Member
I am using oracle 10.2.0.1.

I had a code like as below procedure check_a which call procedure check_b.
and now chcek_b repeatedly calls it self.
proc check_a()
as
begin

check_b();

end;

---------------
procedure check_b()
as
begin

 for i in(select * from---)
   loop
   
   chcek_b();
   end loop;

end;

when I am doing the recursive call ,depending upon certain variable value I need to break the recursive call;
I have checked with the below code
procedure check_b()
as
begin

 for i in(select * from---)
   loop
   
   chcek_b();
   if val = 0 then
    exit;
   end if;
   end loop;

end;

But it is not working the previous recursive call that are in call stack are getting executed after this.
Also at the same time I need to pass value of a variable in check_a from check_b ,and to print it at console .

I do not know whether I am able to make the above problem clear or not Sad

Please help me how to solve the problem.

[Updated on: Sat, 18 October 2008 00:46] by Moderator

Report message to a moderator

Re: handling recursive call in pl/sql [message #354358 is a reply to message #354325] Sat, 18 October 2008 00:50 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is not really clear.
Where does val come from?
Post something that is really working and is representative of what you want to do. Use a small demo table if you need it.

Before, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format and indent the code.
Use the "Preview Message" button to verify.

Regards
Michel
Re: handling recursive call in pl/sql [message #354371 is a reply to message #354325] Sat, 18 October 2008 03:58 Go to previous messageGo to next message
sabbir_ru
Messages: 6
Registered: August 2008
Junior Member
I dont think there is a termination condition here.
Re: handling recursive call in pl/sql [message #354417 is a reply to message #354325] Sat, 18 October 2008 13:13 Go to previous message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
You are in an infinite loop or recursion because you never actually reach the termination test. Try putting the if statement before the call to call_b(). This way you will get a chance to exit before you go down another level.

Good luck, Kevin
Previous Topic: Select against function or procedure
Next Topic: Trigger not getting the CLOB data
Goto Forum:
  


Current Time: Fri Dec 09 15:24:05 CST 2016

Total time taken to generate the page: 0.10624 seconds