database - Is it possible one procedure can call another procedure inside a package body? -


question-: possible 1 procedure can call procedure inside package body?(let's want declare 2 procedure inside package body(not in package specification). p1 & p2 procedures.is possible p1 can call p2 inside package body?)

yes, otherwise packages lose lot of functionality. procedure defined in package body not in specification private, , cannot invoked outside package; of course can within.

however, called procedure has defined before caller within package body source:

create or replace package p42 end p42; /  package p42 compiled  create or replace package body p42  procedure p2 begin   null; end;  procedure p1 begin   p2; end;  end p42; /  package body p42 compiled no errors. 

if have them other way around won't compile:

create package body p42  procedure p1 begin   p2; end;  procedure p2 begin   null; end;  end p42; /  package body p42 compiled errors: check compiler log errors package body stackoverflow.p42:  line/col error -------- ------------------------------------------ 5/3      pls-00313: 'p2' not declared in scope 5/3      pl/sql: statement ignored 

if don't want define them in order, or can't because have lots of procedures dependencies can't organised, can declare called procedure time before it's used - still within body, , using same syntax public procedure in specification:

create or replace package body p42  -- declare private procedure can called before defined procedure p2;  procedure p1 begin   p2; end;  procedure p2 begin   null; end;  end p42; /  package body p42 compiled no errors. 

this summarised in documentation:

before invoking procedure, must declare , define it. can either declare first (with procedure_declaration) , define later in same block, subprogram, or package (with procedure_definition) or declare , define @ same time (with procedure_definition).

as package specification, if procedure has arguments declaration has match. , true functions well, of course.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -