If I do the following, everything is fine:
declare
l_foo clob;
begin
select
regexp_replace(
dbms_metadata.get_ddl('USER', 'SCOTT', null) ||
dbms_metadata.GET_GRANTED_DDL ('SYSTEM_GRANT', 'SCOTT') ||
dbms_metadata.GET_GRANTED_DDL ('OBJECT_GRANT', 'SCOTT') ||
dbms_metadata.GET_GRANTED_DDL ('ROLE_GRANT', 'SCOTT')
,'"' || chr(10), '";' || chr(10))
into l_foo
from dual;
end;
/
But if I wrap this in a procedure:
create procedure tests is
l_foo clob;
begin
select
regexp_replace(
dbms_metadata.get_ddl('USER', 'SCOTT', null) ||
dbms_metadata.GET_GRANTED_DDL ('SYSTEM_GRANT', 'SCOTT') ||
dbms_metadata.GET_GRANTED_DDL ('OBJECT_GRANT', 'SCOTT') ||
dbms_metadata.GET_GRANTED_DDL ('ROLE_GRANT', 'SCOTT')
,'"' || chr(10), '";' || chr(10))
into l_foo
from dual;
end;
/
And execute the procedure by "exec tests;" then I catch a object SCOTT of type USER not found in schema SCOTT.
Why is this and how do I get around?
Thanks Chris
Oracle Documentation states:
To do this, you must add
authid
to your procedure.