I am new to oracle, I am trying to grant the roles to the users via a procedure. I am receiving the following error. can someone please help me with this?
declare stmnt2 varchar(10000);
p_user_name varchar2(20);
v_role_name varchar2(20);
begin
v_role_name := 'ROLE';
p_user_name := 'TOM';
stmnt2 := 'grant '||v_role_name||' to '
||v_user_name||'; '
||' grant connect to '
||v_user_name ;
execute immediate stmnt2;
end;
/
Error report -
ORA-00900: invalid SQL statement
ORA-06512: at line 10
00900. 00000 - "invalid SQL statement"
Thank you
You don't have spaces in your statement:
stmnt2 := 'grant '||v_role_name||' to '||p_user_name;
This must work better.