How to call another Procedure or Function within the same Packge in oracle?

Asked

Viewed 1,960 times

0

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

PACKAGE: CAIXA1

PROCEDURE: CLOSE BOX, SUM TOTAL

FUNCTION: TOTALGRADES

How can I reference TOTAL SUM within CLOSEBOX ?

  • Simply call the function normally within the body of the Procedure. E.g., some_var := TOTALNOTAS(x, y, z);. If you’re not able to do this can be a statement problem or in the order of settings, it’s easier to help you if you post an example code.

1 answer

1


If you declare the objects only in the package body, just make the statement in order for the reference to work (i.e., declare TOTAL SUM before CLOSE box). If you declare the objects in package spec, you can call independent of the order. Example using the 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.