SQL 错误: ORA-06575: 程序包或函数 处于无效状态

lcmj520 2011-06-01 03:43:50
这是一个纠结我一整天的问题了,在SQLDeveloper上写的

我的存储过程就是很简单


create or replace procedure PROC_test
as
begin
select * from dba_tables where owner = 'ACM'
end PRO_test;

执行
call PROC_test();

出现下面的错误:

SQL 错误: ORA-06575: 程序包或函数 PROC_TEST 处于无效状态
06575. 00000 - "Package or function %s 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.


请问有人能解决吗?

万分感激!!!!
...全文
43587 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
weialee 2013-04-23
  • 打赏
  • 举报
回复
感觉还是没有解决!
小营123 2012-04-01
  • 打赏
  • 举报
回复
很牛,解决了。
Rocket_Mark_2010 2012-01-31
  • 打赏
  • 举报
回复
select table_name from dba_tables where owner = 'ACM';
存储过程里面进行赋值是不是要这样做的?
select table_name from dba_tables where owner := 'ACM';
我看报错的信息那里好像有这个意思
yangqm22 2011-06-02
  • 打赏
  • 举报
回复
正解,如果想测试写存储过程也写点有意义的,这样写是不能通过。[Quote=引用 3 楼 bobo12082119 的回复:]
create or replace procedure PROC_test
as
begin
select * from dba_tables where owner = 'ACM'
end PRO_test;
这是一个没有意义的语句;


select col into v_col from table_name where ......
[/Quote]
lcmj520 2011-06-02
  • 打赏
  • 举报
回复
拜托各位大哥,我知道我是有错,我是初学的,但请各位指点指点好吗?
ycproc 2011-06-02
  • 打赏
  • 举报
回复
存储过程的不规范 问题

肯定写的一塌糊涂

你看看别人的写法
huangdh12 2011-06-01
  • 打赏
  • 举报
回复
存储过程不能只执行一条查询语句。
「已注销」 2011-06-01
  • 打赏
  • 举报
回复
oracle的存储过程不能直接这样写一条select返回数据的,不同于sql server,你这样写没有意义。
而且也通不过。
建议你看这个帖子
http://topic.csdn.net/t/20030707/16/1999981.html
lcmj520 2011-06-01
  • 打赏
  • 举报
回复
根据各位大哥的提示,我现在改成这样,我用的是Oracle 11G 在它自带的SQL Developer上写的代码

create or replace procedure PROC_test3
as
begin
select table_name from dba_tables where owner = 'ACM';
end PROC_test3;

Warning: 执行完毕, 但带有警告
procedure PROC_test3 已编译。

begin
set serveroutput on;
EXEC PROC_test3;
end

错误报告:
ORA-06550: 第 2 行, 第 5 列:
PL/SQL: ORA-00922: 选项缺失或无效
ORA-06550: 第 2 行, 第 1 列:
PL/SQL: SQL Statement ignored
ORA-06550: 第 3 行, 第 6 列:
PLS-00103: 出现符号 "PROC_TEST3"在需要下列之一时:
:= . ( @ % ;
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
304的的哥 2011-06-01
  • 打赏
  • 举报
回复

Connected as SYS
SQL> create or replace procedure pro_test
2 as
3 begin
4 for i in (
5 select table_name from dba_tables
6 where owner='SCOTT') loop
7 dbms_output.put_line('tabels in scott schema:'||i.table_name);
8 end loop;
9 end pro_test;--注意end
10 /

Procedure created

SQL> set serveroutput on;
SQL> set pagesize 100;
SQL> exec pro_test;--调用无参过程只需写过程名

tabels in scott schema:DEPT
tabels in scott schema:EMP
tabels in scott schema:BONUS
tabels in scott schema:SALGRADE
tabels in scott schema:BIN$YCT5xmhFSU+EnAnp/mSHZw==$0
tabels in scott schema:BIN$MuwRbIWjRKiVUurtyIT03w==$0
tabels in scott schema:GOODS_TB1
tabels in scott schema:GOODS_TB2
tabels in scott schema:TEST
tabels in scott schema:BIN$vPkh4GFBSw21ItWKZT4KkA==$0
tabels in scott schema:BIN$BYrKqm3ZSxykDmtNfKVNfA==$0
tabels in scott schema:PROJECT_MANAGE
tabels in scott schema:BIN$Mw8EGfnRS72UzIG/j6X+Ew==$0
tabels in scott schema:SYS_TEMP_FBT
tabels in scott schema:BIN$hUpvDWyHTPKmNcrDdDy4IQ==$0
tabels in scott schema:BIN$DFFcU4qjShmXeco/LcjswQ==$0
tabels in scott schema:BIN$uoKglXK2RnKCr1qQXRoIIg==$0
tabels in scott schema:BIN$/aoGE/7uSauFL3HTtl6wUg==$0
tabels in scott schema:BIN$LRRbWxbsSMWAAbuPUHLjCQ==$0
tabels in scott schema:TEMP_TABLE_SESSION

PL/SQL procedure successfully completed
toadzw 2011-06-01
  • 打赏
  • 举报
回复
你这个过程的触发动作是什么啊,没有触发动作的,兄弟
304的的哥 2011-06-01
  • 打赏
  • 举报
回复
create or replace procedure PROC_test
as
begin
select * from dba_tables where owner = 'ACM'
end PRO_test;
这是一个没有意义的语句;


select col into v_col from table_name where ......
xiaoheixiaobai 2011-06-01
  • 打赏
  • 举报
回复 1
你这个存储过程能编译过?

首先select * from dba_tables where owner = 'ACM' 这句必须要以;结束,
并且必须要有into,或定义成游标才行,

其次end PRO_test这句应该是end PROC_test吧。
tangren 2011-06-01
  • 打赏
  • 举报
回复
1、你的存储过程有错误,编译不通过。处理于无效状态。
2、问题
a.存储过程中隐式游标的select 语句必须要有into子句。
如:select col1 into v_col1 from dba_tables where owner = 'ACM'
col1为表中一字段,v_col1为一变量
b.在存储过程中访问视图dba_tables,没有权限,你需要显式授权。
如登录sys用户,
grant select on dba_tables to 你的用记

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧