We have an oracle procedure which is inside a package. When we are calling that Procedure from .NET (Windows Forms) it is giving Operation timeout errors
After seeing this message "Operation Timeout Error" from the screen,when i go to SqlDeveloper and Compile All Packages then after compiling them, the procedure works very fast and i can retrieve the data in 5 seconds.
Can you anyone tell how to solve this issue and what is the root cause?
You should proabbly analyse why package is getting invalid and need compilation before executing and either eliminate code taht causes invalidation or as previous answer says execute compile before running procedure.
Package can get invalid when you alter some dependent objects (swaping table names or synonyms during some load, altering table, dynamically droping and creating objects that package depends on). Those two threads may help you: What Situations Cause Oracle Packages to Become Invalid? and When does an Oracle Package Specification become INVALID If you're able to eliminate package invalidation it is better if you can't go for compilation before each run of procedure.
One more cause that calling procedure from .NET is not recompiling package can be driver. I met such issue a few years ago and remember that changing driver helped. But I don't remember if we changed to managed or unamanged driver.
Try this before run Procedure
ALTER PACKAGE yourpackage
COMPILE PACKAGE;
Related
The Oracle package has one procedure call TestA, and it is very time consuming, about around 3 minutes to finish.
There is one windows job wrriten in C#, who is invoking this Oracle package and the TestA procedure. While the procedure is still in running status, if someone recompile the Oracle package in PL/SQL, will it affect the normal running result of this windows job?
It won't, because the package can't be compiled if it is in use. Compile attempt will "hang" until the package is "released".
Once if the package starts running you should not touch it or do any compilation.
If you try to compile it on running time it will get hang, until the process gets released the compilation process won't happen.
If I have 1 Package with 2 procedures (A & B) what would happen to package A if it was executing and I needed to edit procedure B and recompile the overall package body.
Would A error due to the recompiling of the package or would it still fire off?
Many Thanks
You cannot compile package or package body if the procedure A is working because you will get acquire nowait timeout until A finishes.
If the procedure is being executed, compilation will fail (actually, it'll wait until the package is released, i.e. nobody uses it).
So I've taken an export (using Data Pump) from an Oracle 10g schema where all the PLSQL packages were encrypted using Oracle's Wrap utility. The problem is when I do an import of this into a new schema, all my packages are invalid, and trying a manual compile doesn't work.
SQL> ALTER PACKAGE mypackage compile;
Warning: Package altered with compilation errors.
SQL> show errors
Errors for PACKAGE MYPACKAGE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
36/2 PLS-00103: Encountered the symbol "2"
So what's the solution to recompiling all these invalid packages?
Try using the system DBMS_UTILITY.COMPILE_SCHEMA procedure to compile your schema objects. This procedure will determine the order in which to compile your objects and even handles circular dependencies. After a scripted schema build it's a good procedure to call for clean up.
BEGIN
DBMS_UTILITY.COMPILE_SCHEMA('MYSCHEMA');
END;
/
I'd be curious to know how well it handles wrapped objects.
So it appears there is no "fix" for this issue, only workarounds, none of which are ideal.
Redo the export and import using the old exp and imp programs (instead of data pump)
If you have .SQL files containing the package definitions, you can manually compile them in SQL*Plus (might be thousands of files making this a big job).
You can patch the database (see Metalink article 460267.1)
Our biggest client (150 billion $ of turnover) is afraid about compiling package during the online production time can cause database to hang.
I think it is impossible since the package I want to compile are alone and isolated. They are used to correct data or to analize them.
My chief told something about SGA? Is it possible?
What do you think about?
Compiling a PL/SQL package in online production is problematic if:
the package is currently being executed, or
the package has state (such a body variables) and has been used in one of the sessions that's still logged in
The former can block sessions (most likely just the one that compiles the packages due to a library cache pin lock), the latter one will lead to the following error message in all session that try to use the package again after the compiliation:
ORA-04061: existing state of package body "SCHEMA.PACKAGE" has been invalidated
I don't think there's any specific problem related to the SGA.
Sometimes when I browse views or packages in Oracle SQL Developer they have a red icon next to them, indicating that there was a compile error. This seems to randomly happen to objects that compile without any errors or warnings.
They continue to work even with the red icon, but it's confusing and makes me wonder if I'm missing something. What can I do to find out why these objects are being marked as having problems?
I have seen the same; most of the time when a sub procedure was modified and required compilation.
Oracle SQL Developer is not the finest bit of SW engineering. In general i think oracle should just do what they can do good, that is databases ;) Only saying this to indicate that i would not worry to much about such glitches.
I have not seen that problem myself, but i could imagine that this happens when a database object (e.q a table) this package is using has been altered. Even through the package still compiles, oracle somehow marks them. In jdbc, you would get an 'existing state of package has been discarded' message on the first call to the package. Just a guess, it might just be an error, i would not wonder to much, looking at the quality of their java products in general ;)
Oracle will recompile invalid packages on the fly - that's why invalid packages will often work properly.
As others have pointed out, packages will become invalid if any referenced object is altered. The package may or may not compile cleanly - it depends on how the object is altered.