简体   繁体   English

ORA-01422软件包/触发器的重新编译/重新验证错误(不执行)

[英]ORA-01422 error on recompilation/revalidation (NOT EXECUTION) of package/trigger

I'm running into a problem where I'm trying to grant execution on a package to another schema. 我遇到了一个问题,我试图将某个程序包的执行授予其他模式。

GRANT EXECUTE ON PP.PKG_PROF TO PPSERVICE;

Looks like Oracle attempts to recompile/revalidate the package before making the grant. 看起来Oracle尝试在授予授权之前尝试重新编译/重新验证软件包。 However it is failing with the following error: 但是,它失败并显示以下错误:

GRANT EXECUTE ON PP.PKG_PROF TO PPSERVICE
Error report -
SQL Error: ORA-04045: errors during recompilation/revalidation of PP.PKG_PROF
ORA-20000: ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 83
04045. 00000 -  "errors during recompilation/revalidation of %s.%s"
*Cause:    This message indicates the object to which the following
       errors apply.  The errors occurred during implicit
       recompilation/revalidation of the object.    
*Action:   Check the following errors for more information, and
       make the necessary corrections to the object.

But if i look at the code on line 83, it executes the following query: 但是,如果我看第83行的代码,它将执行以下查询:

select 'x' into vtemp 
from cust_field_vals
where cust_fields = vin_cust_fields
and userid = vin_user_id;

vin_cust_fields and vin_user_id are parameter based values that are provided when the procedure in the package gets called. vin_cust_fields和vin_user_id是基于参数的值,在调用包中的过程时会提供这些值。

My question is: what in the world is oracle doing? 我的问题是:oracle在做什么? I understand that a "SELECT INTO" can theoretically return more than the requested number of rows (which would need to be one in this case), but since it doesn't know what my vin parameters are, how can it make that assessment? 我了解到,“ SELECT INTO”理论上可以返回的行数超出了请求的行数(在这种情况下,行数必须为1),但是由于它不知道我的vin参数是什么,它如何进行评估? Why is a recompilation/revalidation throwing what essentially amounts to an exception for a data anomaly which it shouldn't even be looking at for what I'm trying to do (ie: i'm not trying to actually execute the procedure). 为什么重新编译/重新验证会引发本质上等于数据异常的异常,而该异常甚至不应该针对我要执行的操作进行查找(即:我不是在试图实际执行该过程)。

This is not the first time I've seen this, and if I remember correctly, I even think it's happened on recompilation of triggers as well (not when inserting data). 这不是我第一次看到这种情况,如果我没记错的话,我什至认为它也发生在触发器的重新编译中(而不是在插入数据时)。

Any thoughts? 有什么想法吗? Thanks! 谢谢!

apparently, the problem was the package i was trying to GRANT execute on was "invalid" even though there were no actual code errors. 显然,问题是我尝试对其进行授权的程序包“无效”,即使没有实际的代码错误。 Compiling the body first was generating the above mentioned error. 首先编译主体会产生上述错误。 If I manually compiled the package spec first, then the body, the error went away and the grant executed normally. 如果我先手动编译软件包规格,然后编译主体,错误就会消失,并且授权会正常执行。 No code errors were present in the package, it was just stuck in an invalid state it could not get out of. 软件包中没有代码错误,它只是停留在无法摆脱的无效状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM