This is my first attempt at creating a package, so I must be missing something really really obvious (nothing that I've Googled for seems to even consider it worth mentioning).
Obviously, if you have procedures in your package body that are not included in the specification section, then those procedures are private. The problem I've got is that I can't seem to figure out how to reference those private packages once I've made them. And SQL Developer refuses to give me any message more useful than 'execution completed with warning', which doesn't help...
As an example, this is what I've been trying that doesn't work (just throws the aforementioned compiler error):
CREATE OR REPLACE PACKAGE BODY testPackage AS
PROCEDURE privateProc; --Forward declaration
PROCEDURE publicProc IS
BEGIN
EXECUTE privateProc();
END;
PROCEDURE privateProc IS
BEGIN
DBMS_OUTPUT.PUT_LINE('test');
END;
END testPackage;
I've also tried referring to it as testPackage.privateProc
, which hasn't worked either.
What am I doing wrong?
I think you should do this:
CREATE OR REPLACE PACKAGE BODY testPackage AS
PROCEDURE privateProc; --Forward declaration
PROCEDURE publicProc IS
BEGIN
privateProc();
END;
PROCEDURE privateProc IS
BEGIN
DBMS_OUTPUT.PUT_LINE('test');
END;
END testPackage;
Just call privateProc as if it is part of the language. Execute is for running DML or SQL inside your PL/SQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With