--动态sql create or replace procedure AA (id number) as
    strsql varchar2(500);
begin
    strsql:='create or replace view b as select * from c where nid=:v_id with read only';
    execute immediate strsql using id;
    ....
end;
/

解决方案 »

  1.   

    这样写了,执行
    execute aa(2);
    提示错误:
    ERROR 位于第 1 行:
    ORA-01027: 在数据定义操作中不允许对变量赋值
    ORA-06512: 在"AA", line 5
    ORA-06512: 在line 1怎么办啊??
      

  2.   

    create  or  replace  procedure  AA  (id  number)  
    as  
    begin  
    execute immediate 'create  or  replace  view  b  as      
            select  *  from  tb  where  col1='||id||'  with  read  only';  
    end;  
    /
      

  3.   

    还是提示错误啊!ERROR 位于第 1 行:
    ORA-01031: 权限不足
    ORA-06512: 在"AA", line 4
    ORA-06512: 在line 1怎呢办?求救!
      

  4.   

    grant create view to user
      

  5.   

    connect system/manager
    grant create view to youruser;