CREATE TABLE my_data (n NUMBER)
Table created.
Apply ACCESSIBLE BY To Subprograms and Specify "Unit Kind"
CREATE OR REPLACE PACKAGE pkg
AUTHID DEFINER
IS
PROCEDURE do_this;
PROCEDURE this_for_proc_only
ACCESSIBLE BY (PROCEDURE generic_name);
PROCEDURE this_for_trigger_only
ACCESSIBLE BY (TRIGGER generic_name);
PROCEDURE this_for_any_generic_name
ACCESSIBLE BY (generic_name);
/* This will not work - only program units can be named, not subprograms */
PROCEDURE this_for_pkgd_proc1_only
ACCESSIBLE BY (PROCEDURE pkg1.myproc1);
END;
Package created.
CREATE OR REPLACE PACKAGE BODY pkg
IS
PROCEDURE do_this
IS
BEGIN
NULL;
END;
PROCEDURE this_for_proc_only
ACCESSIBLE BY (PROCEDURE generic_name)
IS
BEGIN
NULL;
END;
PROCEDURE this_for_trigger_only
ACCESSIBLE BY (TRIGGER generic_name)
IS
BEGIN
NULL;
END;
PROCEDURE this_for_any_generic_name
ACCESSIBLE BY (generic_name)
IS
BEGIN
NULL;
END;
PROCEDURE this_for_pkgd_proc1_only
ACCESSIBLE BY (PROCEDURE pkg1.myproc1)
IS
BEGIN
NULL;
END;
END;
Package Body created.
Trigger Invokes Trigger-Only Procedure
CREATE OR REPLACE TRIGGER generic_name
BEFORE INSERT
ON my_data
FOR EACH ROW
DECLARE
BEGIN
pkg.this_for_trigger_only;
END;
Trigger created.
Trigger Invokes Procedure-Only Procedure
CREATE OR REPLACE TRIGGER generic_name
BEFORE INSERT
ON my_data
FOR EACH ROW
DECLARE
BEGIN
pkg.this_for_proc_only;
END;
Error at line: 26More Details: https://docs.oracle.com/error-help/db/ora-24344
Procedure Invokes Procedure-only Procedure
CREATE OR REPLACE PROCEDURE generic_name
AUTHID DEFINER
IS
BEGIN
pkg.this_for_proc_only;
END;
Procedure created.
Procedure Invokes Trigger-only Procedure
CREATE OR REPLACE PROCEDURE generic_name
AUTHID DEFINER
IS
BEGIN
pkg.this_for_trigger_only;
END;
Errors: PROCEDURE GENERIC_NAME Line: 5 PLS-00904: insufficient privilege to access object THIS_FOR_TRIGGER_ONLYMore Details: https://docs.oracle.com/error-help/db/ora-24344
Trigger Can Invoke "Any Kind" Procedure
CREATE OR REPLACE TRIGGER generic_name
BEFORE INSERT
ON my_data
FOR EACH ROW
DECLARE
BEGIN
pkg.this_for_any_generic_name;
END;
Trigger created.
Procedure Can Invoke "Any Kind" Procedure
CREATE OR REPLACE PROCEDURE generic_name
AUTHID DEFINER
IS
BEGIN
pkg.this_for_any_generic_name;
END;
Procedure created.
CREATE OR REPLACE PACKAGE pkg1
AUTHID DEFINER
IS
PROCEDURE myproc1;
PROCEDURE myproc2;
END;
Package created.
ACCESSIBLE BY Cannot Restrict to Subprogram.
CREATE OR REPLACE PACKAGE BODY pkg1
IS
PROCEDURE myproc1
IS
BEGIN
pkg.this_for_pkgd_proc1_only;
END;
PROCEDURE myproc2
IS
BEGIN
NULL;
END;
END;
Errors: PACKAGE BODY PKG1 Line: 6 PLS-00904: insufficient privilege to access object THIS_FOR_PKGD_PROC1_ONLYMore Details: https://docs.oracle.com/error-help/db/ora-24344