1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| SQL> create or replace procedure p (p_nom_table varchar2, p_param varchar2) as
l_verif_nom_table varchar2(30);
l_query varchar2(1000);
l_usr_bool varchar2(1);
begin
l_verif_nom_table := dbms_assert.sql_object_name(p_nom_table);
l_query := 'select decode(username,''SYS'',''T'',''F'') as usr_bool from '|| l_verif_nom_table || ' where username = :usr';
dbms_output.put_line(l_query);
execute immediate l_query into l_usr_bool using p_param;
dbms_output.put_line(l_usr_bool);
end;
/
Procedure created.
SQL> exec p('ALL_USERS','SYSTEM');
select decode(username,'SYS','T','F') as usr_bool from ALL_USERS where username = :usr
F
PL/SQL procedure successfully completed.
SQL> |
Partager