How to call another procedure or function within the same packge in oracle?

0

I have varaias procedures and functions within the same package. How can I reference some inside in my PL-SQL code?

PACKAGE : BOX1

PROCEDURE : CLOSE, SOMATOTAL

FUNCTION : TOTALNOTES

How can I reference SOMATOTAL within CLOSE?

    
asked by anonymous 23.01.2018 / 21:28

1 answer

1

If you declare the objects only in the package body, simply make the declaration in order for the reference to work (ie declare SOMATOTAL before CLOSE). If you declare the objects in the package spec, you can call independently of the order. Example using statement in spec:

create or replace package CAIXA1 is

  procedure FECHARCAIXA;

  procedure SOMATOTAL;

  function TOTALNOTAS return number;

end CAIXA1;

create or replace package body CAIXA1 is

  procedure FECHARCAIXA is
  begin
    dbms_output.put_line('FECHARCAIXA');
    SOMATOTAL;
  end;

  procedure SOMATOTAL is
  begin
    dbms_output.put_line('SOMATOTAL');
  end;

  function TOTALNOTAS return number is
  begin
    dbms_output.put_line('TOTALNOTAS');
  end TOTALNOTAS;

end CAIXA1;

exec CAIXA1.FECHARCAIXA;

Expected output:

FECHARCAIXA
SOMATOTAL
    
24.01.2018 / 14:37