Din procedure ser ud til at være en del af en pakke. I en pakke kan du kun angive invoker-rettigheder (AUTHID CURRENT_USER
) på pakkeniveau. Du kan ikke indstille det til hver enkelt procedure.
Flyt enten invoker-rettighederne til pakkeniveauet:
CREATE OR REPLACE PACKAGE pkg
AUTHID CURRENT_USER
AS
PROCEDURE BCKUP;
-- more types, procedures and functions
END pkg;
CREATE OR REPLACE PACKAGE BODY pkg
AS
PROCEDURE BCKUP
statusmsg VARCHAR2(400);
BEGIN
--Backup records
EXECUTE IMMEDIATE 'CREATE TABLE schemaname.tabname AS SELECT pgm.* FROM XYZ pgm, IJK prf WHERE prf.col1=pgm.col1 AND prf.ID IN(SELECT ID FROM TAB2)';
COMMIT;
EXCEPTION WHEN OTHERS THEN
statusmsg :='SQL ERRROR CODE ' || SQLCODE|| ' -ERROR- ' ||SQLERRM;
dbms_output.put_line('ERROR : ' || statusmsg);
END BCKUP;
END pkg;
Eller opret en global procedure (dvs. på skemaniveau og ikke på pakkeniveau):
CREATE OR REPLACE PROCEDURE BCKUP
AUTHID CURRENT_USER AS
statusmsg VARCHAR2(400);
BEGIN
--Backup records
EXECUTE IMMEDIATE 'CREATE TABLE schemaname.tabname AS SELECT pgm.* FROM XYZ pgm, IJK prf WHERE prf.col1=pgm.col1 AND prf.ID IN(SELECT ID FROM TAB2)';
COMMIT;
EXCEPTION WHEN OTHERS THEN
statusmsg :='SQL ERRROR CODE ' || SQLCODE|| ' -ERROR- ' ||SQLERRM;
dbms_output.put_line('ERROR : ' || statusmsg);
END BCKUP;