Authid Current_User:-
The authid current_user is used when you want a piece of code (PL/SQL) to execute with the privileges of the current user, and NOT the user ID that created the procedure. This is termed a "invoker rights", the opposite of "definer rights".
The authid current_user is the opposite of authid definer.
In the same sense, the authid current_user is the reverse of the "grant execute" where the current user does not matter, the privileges of the creating user are used.
PL/SQL, by default, run with the privileges of the schema within which they are created no matter who invokes the procedure. In order for a PL/SQL package to run with invokers rights AUTHID CURRENT_USER has to be explicitly written into the package.
Examples:-
CREATE PROCEDURE IN SCOTT SCHEMA
CREATE OR REPLACE PROCEDURE XXC05_AUTHID_CURENT_USER
IS
BEGIN
insert into XXC05_TEST values(7,'G ');
COMMIT;
END XXC05_AUTHID_CURENT_USER;
CREATE OR REPLACE PROCEDURE XXC05_AUTHID_CURENT_USER1 AUTHID CURRENT_USER
IS
BEGIN
insert into XXC05_TEST values(10,'I ');
COMMIT;
END XXC05_AUTHID_CURENT_USER1;
EXECUTE IN HR SCHEMA
procedure XXC05_AUTHID_CURENT_USER work normally.
But procedure XXC05_AUTHID_CURENT_USER1 give error 'table or view does not exits'.
If we give permission on all object which is declare in that procedure then it work normally.
Thanks
Sajal Agarwal
No comments:
Post a Comment