需要设计一个存储过程,用来给其他用户下的表定义触发器,过程接收两个参数:schema_name 和 table_name,但是遇到了权限问题。为了验证这个问题,使用一段简单的代码,其中,执行用户为fxy,具有DBA权限,然后向u4test中插入一条记录,代码如下:
CREATE or replace procedure tproc_u4test as 
begin
insert into "U4TEST"."STUDENT"(sid,sname) values('okk','kkkk');
end;然后报出ora-06575的错误
Package or function string is in an invalid state
Cause: A SQL statement references a PL/SQL function that is in an invalid state. Oracle attempted to compile the function, but detected errors.
Action: Check the SQL statement and the PL/SQL function for syntax errors or incorrectly assigned, or missing, privileges for a referenced object.直接执行 insert into "U4TEST"."STUDENT"(sid,sname) values('okk','kkkk'); 是没有问题的,但是放到存储过程里就不行了,对于Oracle的权限系统比较模糊,不知道这里怎么解决,还请高手赐教!

解决方案 »

  1.   

    你的存储过程写的不对吧,编译都没通过,你怎么执行呢?CREATE or replace procedure tproc_u4test as 
    begin
    insert into "U4TEST"."STUDENT"(sid,sname) values('okk','kkkk');
    end;
    end;
      

  2.   

    这样就多了一个end吧?编译了一下,在sql developer 中会报 错误(6,1): PLS-00103: 出现符号 "END"
      

  3.   

    在U4TEST 下执行grant insert on STUDENT to 现用户.
      

  4.   

    grant insert on STUDENT to FXY
      

  5.   

    在fxy下直接执行 insert into "U4TEST"."STUDENT"(sid,sname) values('okk','kkkk'); 是没问题的,fxy用户具有dba权限
      

  6.   

    SQL> grant dba to test;--编译过程不成功
     
    Grant succeeded
     
    SQL> grant sysdba to test;--编译过程不成功
     
    Grant succeeded
     
    SQL> grant select any table to test;--先前报错对象不存在,现在报错无权限.
     
    Grant succeeded
     
    SQL> grant insert any table to test;--重新编译过程成功
     
    Grant succeeded
     
    SQL> 
      

  7.   

    insert 和 select权限还是要赋的.
      

  8.   

    这个确实是,执行了grant insert any table to _user.
    但是不进行grant之前,直接执行 insert into other_user.table_name却是有权限的啊,这个很郁闷啊
      

  9.   

    这个确实是,执行了grant insert any table to _user.就是可以的。
    但是不进行grant之前,直接执行 insert into other_user.table_name却是有权限的啊,这个理解上有些乱啊
      

  10.   

    在过程里调用还是的显示赋予权限grant insert on "U4TEST"."STUDENT" to fxy这个问题具体也不清楚
    以前我过程里面动态建视图 也报权限问题 后面手动授权就可以了
      

  11.   

    确实是这样子,看来要想具体解决还得全面学习Oracle的权限系统,好纠结的机制~~