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. 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:
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.
My question is: what in the world is oracle doing? 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? 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.
Related
I am trying to create function in oracle 12c database using liquibase, below is the sql formatted changelog. I am doing negative testing to see what response i get, purposefully using wrong keyword returns
--liquibase formatted sql
--changeset your.name:1 failOnError:true
CREATE OR REPLACE FUNCTION get_tab1_count RETURNS NUMBER AS
l_count NUMBER;
BEGIN
SELECT COUNT(*)
INTO l_count
FROM person3;
RETURN l_count;
END;
/
This change log gets updated successfully, but as expected in the database I have a function now which has compilation errors,
Compilation errors for FUNCTION GET_TAB1_COUNT
Error: PLS-00103: Encountered the symbol "RETURNS" when expecting one of the following:
( return compress compiled wrapped
my question is am i doing something wrong, that liquibase is giving a "update has been successful" message? Or is this expected behaviour? I have tried adding failOnError:true in the changelog to see if it will actually now fail as there is a compilation error during function creation, but it does not make any difference. I would think that, liquibase would give some sort of failure message when there is a compilation error like the above, am I wrong?
Liquibase is just running your changeset as sql being passed to a JDBC connection.
quoting a colleague: "the jdbc connection gives us for a response and I THINK most databases are just "yes, you created that fine" even though it is not actually valid at this point. But, they don't tell us until we run it"
As a work around you could write a script that checks for compilation errors and fails when it finds any issues. Create an execute change set with runAlways="true"
I know
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
will return the line number , where the error occurred.
is there any way to get the actual code statement which give the error in Oracle 11g?
There isn't a similar mechanism to get the source code automatically.
You could, in principal, get the source code for that line (and maybe surrounding lines) from the user_source or all_source data dictionary views.
The scenario you've described, though, is that you don't have access to the source on the database that is throwing the initial exception. The calling PL/SQL block that currently catches and formats the exception can only see the remote source if the database link user has been granted privileges to see the code in that database, and you've implied it doesn't. You can verify by querying all_source#db_link for the owner and package/procedure in the stack trace. And always try asking for it if you don't ave it already - the source may well not be public on purpose, of course.
If you did have that access you could look at the source manually over that link. You could also query that within your local exception handler, and - as a debugging tool - output that, say with dbms_output. That's then no different to looking at local code, you just have the DB link in the query. But exposing that remote code to whoever calls your local procedure might not be sensible.
When I'm trying to drop table then I'm getting error
SQL Error: ORA-00604: error occurred at recursive SQL level 2
ORA-01422: exact fetch returns more than requested number of rows
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
One possible explanation is a database trigger that fires for each DROP TABLE statement. To find the trigger, query the _TRIGGERS dictionary views:
select * from all_triggers
where trigger_type in ('AFTER EVENT', 'BEFORE EVENT')
disable any suspicious trigger with
alter trigger <trigger_name> disable;
and try re-running your DROP TABLE statement
I noticed following line from error.
exact fetch returns more than requested number of rows
That means Oracle was expecting one row but It was getting multiple rows. And, only dual table has that characteristic, which returns only one row.
Later I recall, I have done few changes in dual table and when I executed dual table. Then found multiple rows.
So, I truncated dual table and inserted only row which X value. And, everything working fine.
I know the post is old and solved, but maybe someone is facing or will face my situation, so I want to leave the aquired knowledge here, after deal with the error for a week. I was facing the error: "ORA-00604: error occurred at recursive SQL level 1" , but with the internal error: " ORA-06502: error: character string buffer too smal numeric or value", this happened only when I try to logon the database, and using an specific driver, trying to connect from an Visual Studio C# application, the weirdest thing on that moment was that I connect from SQLDeveloper or TOAD and everything worked fine.
Later I discovered that my machine name had this format "guillermo-aX474b5", then I proceed to rename it like this "guillermo" without the "-" and the other stuff, and it worked!! Looks like in some drivers and situations, ORACLE Database does'nt like the "-" in the LogOn connection.
Hope it helps!
I got this error
Error: ORA-00604: error occurred at recursive SQL level 1 ORA-20033 user doesnot change in this schema , ORA-06512
in my oracle package.
I run it step by step and it is okey but when I want to compile package it gives this error?
can anyone help me?
thanks.
This seems strange, because ORA-20033 is in the range reserved for user-defined error messages, so you may have code in the database that is preventing the package from compiling.
Your coworkers ought to now what this is, or you could query the DBA_SOURCE table for code that defines and raises this error. A DDL trigger on package creation, possibly.
I have a java web app that calls the oracle plsql procedure from ibatis xml file. this procedure captures the audit information of the table. so when multiple users modifies a table this stored procedure .after certain time i receive the following error.
--- The error occurred in example.xml.
--- The error occurred while applying a parameter map.
--- Check the example.params.
Check the statement (update procedure failed).
Cause: java.sql.SQLException: ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure "PUBLIC.PLITBLM"
ORA-06508: PL/SQL: could not find program unit being called:
"PUBLIC.PLITBLM" ORA-06512: at "AUDIT", line 279
ORA-06512: at line 1
call from ibatis
{call AUDIT(?,?,?,?,?,?,'val')}
call from java web app
Map _temp = new HashMap(params);
_temp.put("OPERATION_TYPE",operation);
sqlMapper.insert("call_proc_audit",_temp);
return false;
The plsql procedure has only execute immediate for insert,update and delete.
I have removed the code due to security.
The PLITBLM package is part of the standard Oracle build; apparently it handles index organized tables. It's not documented in any detail because it's not something we need to call directly. Find out more. It's likely that some standard Oracle functionality has dependencies on it.
As to why your program hurls that exception, that's a bit of a facer. The package is created by a script in the Oracle home $ORACLE_HOME/rdbms/admin/plitblm.sql. However, it cannot be run on its own but only as part of catproc,sql. This builds the data dictionary and other things, and is run as part of the Oracle installation process.
Perhaps you have a botched install?
Interestingly, the actual PLITBLM package is owned by SYS but the error message references PUBLIC, which suggests it might just be a missing public synonym. However, if catproc,sql has not run successfully there may be other lurking nasties. You really need a DBA to check the database, and if necessary re-run catproc,sql.