Re: "Circular" program units in a library

From: Tim Taylor <ttaylor_at_us.oracle.com>
Date: Mon, 19 Oct 1998 13:28:52 -0400
Message-ID: <362B76D3.F6E45B96_at_us.oracle.com>


Lisa,

Instead of having four procedures in your library, create a package. Declare the two procedure which must call each other in the package spec. Here's a simple (and very contrived example):

create or replace package Test as

procedure One;
procedure Two;

end Test;
/
show errors

create or replace package body Test as
 g_count number := 0;

procedure One is
begin
 dbms_output.put_line('I am in procedure One');  if g_count < 5 then
  g_count := g_count + 1;
  Two;
 end if;
end One;

procedure Two is
begin
 dbms_output.put_line('I am in procedure Two');  g_count := g_count + 1;
 One;
end Two;

procedure Three is
begin
 dbms_output.put_line ('I am in procedure Three'); end Three;

end Test;
/
show errors

Here's a sample SQL Plus session showing the output:

SQL> set serveroutput off
SQL> set serveroutput on
SQL> exec test.one

I am in procedure One
I am in procedure Two
I am in procedure One
I am in procedure Two
I am in procedure One
I am in procedure Two
I am in procedure One

PL/SQL procedure successfully completed.

SQL> exec test.two
I am in procedure Two
I am in procedure One

PL/SQL procedure successfully completed.

SQL> exec test.three
begin test.three; end;

*
ERROR at line 1:

ORA-06550: line 1, column 12:
PLS-00302: component 'THREE' must be declared
ORA-06550: line 1, column 7:

PL/SQL: Statement ignored

SQL> You cannot run procedure Three because its not declared in the package spec.

Good luck,

Tim Taylor

Lisa Tassoni wrote:

> Hello everyone,
>
> In dev2000,
> I have a library form with 4 program units. 2 program units "call" each
> other:
> in the text of unit1: unit2 is named, thus called and
> in the text of unit2: unit1 is named, thus called.
>
> The compiler gives errors when I compile the file. I tried compiling
> with the tool in windows95 and in Unix. I get the same errors.
>
> Is this a bug? Any workaround?
>
> THanks in advance.
Received on Mon Oct 19 1998 - 19:28:52 CEST

Original text of this message