JUST DO IT ~

我只想当个程序员

plsql 包,tomcat jdbc 调用存储过程老是报错 ORA-06508: PL/SQL: could not find program unit being called:

sqlplus 外面执行正常.

tomcat调用老有问题.多调用几次久正常.

 

可能是包中的全局变量引起的.

 

 

If so, that's because your package is stateful:

The values of the variables, constants, and cursors that a package declares (in either its specification or body) comprise its package state. If a PL/SQL package declares at least one variable, constant, or cursor, then the package is stateful; otherwise, it is stateless.

When you recompile the state is lost:

If the body of an instantiated, stateful package is recompiled (either explicitly, with the "ALTER PACKAGE Statement", or implicitly), the next invocation of a subprogram in the package causes Oracle Database to discard the existing package state and raise the exception ORA-04068.

After PL/SQL raises the exception, a reference to the package causes Oracle Database to re-instantiate the package, which re-initializes it...

You can't avoid this if your package has state. I think it's fairly rare to really need a package to be stateful though, so you should revisit anything you have declared in the package, but outside a function or procedure, to see if it's really needed at that level. Since you're on 10g though, that includes constants, not just variables and cursors.

But the last paragraph from the quoted documentation means that the next time you reference the package in the same session, you won't get the error and it will work as normal (until you recompile again).

 

existing state of packages has been discarded means, that your Package had some sort of state.

This is caused by a global variable (or constant) stored in your Package Body.

Since the package has already been used in your session, Oracle assumes that this state is relevant for you. Some of these variables might have different values now, and when you recompile the Body, the values are reset.

This exception is thrown, so that your clients know that they can't rely on those variables any more.

You could try to remove all global variables and constants from the Package Body, or close your session and reconnect before calling the package again.

 

 

参考:

http://stackoverflow.com/questions/2502722/pl-sql-package-invalidated

 

http://stackoverflow.com/questions/19376440/ora-06508-pl-sql-could-not-find-program-unit-being-called

posted on 2014-07-16 21:14 小高 阅读(1624) 评论(0)  编辑  收藏 所属分类: Oracle


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2014年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

常用链接

留言簿(3)

随笔分类(352)

收藏夹(19)

关注的blog

手册

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜