I am trying to create a procedure that receives as a parameter the user to whom they wish to grant the tables permission directly, I know that it would be better with a role and simply grant it, but it is an exercise, to create a procedure that allows to give permission to X user on tables.
I made this code but I see an error in the GRANT CREATE
and the word create (use ORACLE SQL Developer
) is underlined, if I delete it (this sentence), the following sentence is underlined what I put after the GRANT
, in this case, when you delete all the GRANT create table TO usuario;
, the update
of the next sentence is highlighted.
The code is as follows
create or replace PROCEDURE Gran_toAnyTables (usuario varchar2) AS
BEGIN
GRANT create table TO usuario;
GRANT update any table TO usuario;
GRANT insert any table TO usuario;
GRANT select any table TO usuario;
GRANT delete any table TO usuario;
GRANT COMMENT ANY TABLE TO usuario;
GRANT BACKUP ANY TABLE TO usuario;
END Gran_toAnyTables;
And the error that appears to me when compiling it is the following
"PLS-00103: Encountered the symbol" GRANT "when expecting one of the following:
(begin case declare exit for goto if loop mod null pragma raise return select update while with < < continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge "