Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL - Circular dependencies
PL/SQL - Circular dependencies [message #263076] Wed, 29 August 2007 00:44 Go to next message
shanti_21205
Messages: 3
Registered: August 2007
Location: INDIA
Junior Member

Frinds,
I have one question
I am having 2 PL/SQL block, which is having 2 procedure.
procedure A calling procedure B and Procedure B calling procedure A.
How do i compile the PL SQL block.

[mod-edit]modified title.

[Updated on: Wed, 29 August 2007 01:49] by Moderator

Report message to a moderator

Re: PL/SQL [message #263083 is a reply to message #263076] Wed, 29 August 2007 00:56 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Don't use standalone procedures, use a package with both procedures.

Regards
Michel
Re: PL/SQL [message #263088 is a reply to message #263083] Wed, 29 August 2007 01:00 Go to previous messageGo to next message
shanti_21205
Messages: 3
Registered: August 2007
Location: INDIA
Junior Member

So u mean to say this is not possible in PL/SQL block.
Re: PL/SQL [message #263102 is a reply to message #263088] Wed, 29 August 2007 01:33 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
shanti_21205 wrote on Wed, 29 August 2007 08:00
So u mean to say this is not possible in PL/SQL block.
In a single block: yes you can. I'd probably use forward declaration.

Try this script:
DECLARE
-- forward declaration:
  PROCEDURE procedure_b;
  
  PROCEDURE procedure_a(p_b_call_b IN BOOLEAN)
  IS
  BEGIN
    dbms_output.put_line('This is procedure_a');
    IF p_b_call_b THEN
      procedure_b;
    END IF;
  END procedure_a;
  
  PROCEDURE procedure_b
  IS
  BEGIN
    dbms_output.put_line('This is procedure_b');
    procedure_a(FALSE);
  END procedure_b;    


BEGIN
  procedure_a(TRUE);
END;
/
I must say that I never used forward declaration on a production site. I certainly would use packages. In fact, our DBA's are very reluctant on installing standalone procedures or functions.

MHE
Re: PL/SQL [message #263105 is a reply to message #263088] Wed, 29 August 2007 01:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is possible in a PL/SQL block as Maarten showed it.
It is not possible with STORED procedures unless they are in a package.

Regards
Michel
Re: PL/SQL [message #263110 is a reply to message #263102] Wed, 29 August 2007 01:49 Go to previous message
shanti_21205
Messages: 3
Registered: August 2007
Location: INDIA
Junior Member

Thanks ....
Thanks, Must appreciate your methodical approach.
Previous Topic: Accessing duplicate field name in a view
Next Topic: Dynamic SQL ??
Goto Forum:
  


Current Time: Sat Dec 03 12:27:46 CST 2016

Total time taken to generate the page: 0.04894 seconds