Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. -- with schema1
  2. create or replace procedure schema1.EXECUTE_RAW_SQL ( statement in varchar2 )
  3. is begin
  4. execute immediate statement;
  5. exception when others then
  6. raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
  7. end;
  8.  
  9. -- with dba
  10. create user schema2 identified by schema2;
  11. grant connect to schema2;
  12. grant create session to schema2;
  13. grant execute on schema1.EXECUTE_RAW_SQL to schema2;
  14.  
  15. -- with schema2
  16. execute schema1.EXECUTE_RAW_SQL('create table blah ( id number(10), name varchar2(255) )');
  17. -- Error starting at line : 1 in command -
  18. -- BEGIN schema1.EXECUTE_RAW_SQL('create table blah ( id number(10), name varchar2(255) )'); END;
  19. -- Error report -
  20. -- ORA-20001: An error was encountered - -1031 -ERROR- ORA-01031: insufficient privileges
  21. -- ORA-06512: at "schema1.EXECUTE_RAW_SQL", line 5
  22. -- ORA-06512: at line 1
  23.  
  24. -- with dba
  25. grant create table to schema1;
  26.  
  27. -- with schema2
  28. execute schema1.EXECUTE_RAW_SQL('create table blah ( id number(10), name varchar2(255) )');
  29.  
  30. -- with schema1
  31. describe blah;
  32. -- Name Null? Type
  33. -- ---- ----- -------------
  34. -- ID NUMBER(10)
  35. -- NAME VARCHAR2(255)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement