错误如下(xxxxx为储存过程命名)
warning: Procedure created with compilation errors;
该错误直接导致后面执行储存过程报错
PLS-00905: object xxxxx is invalid
字面意思就是创建的储存过程对象无效
解决方案
1.查找错误
#如果是
SQL>show errors procedure xxxxx;
或dba登录查询
SQL>select * from SYS.USER_EERORS where name=upper('xxxxxx');
或(USER为执行存储过程的oracle用户)
SQL>select * from dba_errors where owner='USER';
2. 分析问题
查出来的错误是 utl_file must be declared
去网上搜了一下,发现是因为utl_file这个基础包当前用户没有执行权限,导致定义的utl_file对象无法识别,编译报错,可以查一下
SQL>select owner,object_type from all_objects where object_name='UTL_FILE';
结果显示是 PUBLIC SYNONYM
#PUBLIC是数据库所有用户对象,查看是否具有utl_file包执行权限
SQL>select * from all_tab_privs where grantee='PUBLIC' and table_name='UTL_FILE';
结果显示no row select, 说明没有utl_file包执行权限
3.处理方法
重新授权
SQL>grant execute on UTL_FILE to PUBLIC;
或者只单独给某个用户权限
SQL>grant execute on UTL_FILE to USER;
完成解决,像utl_file这样的oracle基础包还有
utl_tcp,utl_http,utl_smtp等,类似的处理方法一致
特别总结:若遇到存储过程编译报错的问题,先show errors找到问题,再分析解决问题。