Dynamic SQL

PT  :  Necessito mesmo hard coded  na minha script ?
EN :  Do I really need to hard coded  my grant script ?



set serveroutput on size 1000000;

declare
cursor c1 is (
select 'grant select on  wes.' || table_name  || ' to wes_ro'  cmd
from dba_objects
where
owner like 'wes'
and object_type in ('table','table partition','table subpartition','view','materialized view','sequence')
);
begin
for i in c1
loop
dbms_output.put_line(' ran : ' || i.cmd);
execute immediate i.cmd ;
end loop;
end;
/

Comments