Hi,
Can you please help me with the code. I am not sure where I am wrong
the line below does not work GRANT SELECT ON r.OWNER || '.' || r.OBJECT_NAME TO USERTEST1; -- DOES NOT WORK
The code is as below:
set serveroutput on
BEGIN
FOR R IN
(SELECT owner, OBJECT_NAME FROM DBA_OBJECTS WHERE OWNER='SCOTT' and OBJECT_TYPE IN ('TABLE', 'VIEW')
MINUS SELECT owner, TABLE_NAME FROM dba_tab_privs WHERE grantee='SIUD_SCOTT' and OWNER='SCOTT')
-- SIUD_SCOTT is a ROLE
LOOP
-- dbms_output.put_line(R.OBJECT_NAME); -- THIS WORKS
--dbms_output.put_line('GRANT SELECT ON '|| r.OWNER || '.' || r.OBJECT_NAME || ' to USERTEST1;'); -- This works
--'GRANT SELECT ON' || r.owner || '.' || r.OBJECT_NAME || ' to USERTEST1'; -- DOES NOT WORK
GRANT SELECT ON r.OWNER || '.' || r.OBJECT_NAME TO USERTEST1; -- DOES NOT WORK
end loop;
end;
/
Regards,
Daniel