create or replace procedure create_person is
str varchar2(200);
begin
  str := 'create user A0000009 
        identified by aaaaaa
        default tablespace TEMPORARY
        temporary tablespace TEMPORARY
        profile DEFAULT';
   -- Grant/Revoke role privileges 
  --  || 'grant connect to A0000009;'
  --  || 'grant sfgroup to A0000009;'
  
  execute immediate str;
end create_person;这个存储过程 报 immediate 关键字错误?
怎么解决?

解决方案 »

  1.   

    存储过程中,能执行 create 命令,你将immediate去掉
      

  2.   

    先定义一个变量:
    v_sql varchar2(200);v_sql := 'create user A0000009';execute immediate v_sql;这样就可以了
      

  3.   

    805不支持本地动态语句
    用dbms_sql包吧
      

  4.   

    execute immediate在805版本是不可以使用的,它是8i及以上版本的新特性。
    在805中,可以使用dbms_sql包,来解决动态sql的问题。当然,如果,你要在过程中使用create语句,首先要显示授权给这个用户。
      

  5.   

    那到底应该怎么写呢?
    这样写好象还是不行?create or replace procedure create_person
     is
    str varchar2(200);
    begin
      str := 'create user A0000009 
            identified by aaaaaa
            default tablespace TEMPORARY
            temporary tablespace TEMPORARY
            profile DEFAULT';   dbms_sql.execute immediate str;
    end create_person;
      

  6.   

    我试过了,用动态SQL来创建,但是系统提示, EXECUTE不能识别,不知道哪里出了问题?create or replace procedure create_person is
     cursor_name varchar2(400);
    begin
      
     cursor_name := dbms_sql.open_cursor;
     
        DBMS_SQL.PARSE(cursor_name, 'create user A0000009 
            identified by aaaaaa
            default tablespace TEMPORARY
            temporary tablespace TEMPORARY
            profile DEFAULT',
                       dbms_sql.native);
        dbms_sql.execute(cursor_name);
        DBMS_SQL.close_cursor(cursor_name);
    EXCEPTION
    WHEN OTHERS THEN
        DBMS_SQL.CLOSE_CURSOR(cursor_name);
    end create_person;