首页 > 其他 > 详细

存储过程中调用EXECUTE IMMEDIATE的“权限不足”问题

时间:2015-03-18 17:25:00      阅读:307      评论:0      收藏:0      [点我收藏+]

使用plsql 动态创建表时,用户需要具有create any table 权限

例如:

create or replace procedure create_table_test is
tmpstr varchar2(500);
v_cursor number;
j number;
begin
  for i in 10..120 loop
  begin
  tmpstr:= create table DPC_TEST|| i || as select * from DPC_TEST WHERE 1=2;
  dbms_output.put_line(tmpstr);
  --v_cursor := dbms_sql.open_cursor;
  --dbms_sql.parse(v_cursor,tmpstr,dbms_sql.native);
  --j:=dbms_sql.execute(v_cursor);
  execute immediate tmpstr;
  exception
  when others then
  dbms_output.put_line(error create table!);
      DBMS_OUTPUT.put_line(sqlcode :  ||sqlcode); 
      DBMS_OUTPUT.put_line(sqlerrm :  ||sqlerrm); 
  end;
  end loop;
end create_table_test;

在命令行中执行exec create_table_test 时,会遇到权限不足的错误!
需要使用sys用户登录后,执行grant create any table to USER.

 

存储过程中调用EXECUTE IMMEDIATE的“权限不足”问题

原文:http://www.cnblogs.com/zhaosj/p/4347630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!