How to check syntax Oracle stored procedure in SQL Developer? - oracle

In SQL Server Management Studio, there is a "Parse" menu where you can check the syntax of the stored procedure, without running the stored procedure.
Is there a similar thing in Oracle SQL Developer, to check the syntax of the codes in the stored procedure without executing it ? Similar to compiling it, and see if there is any error ?
Thank you.

Yes...but it does that as you type, it's not an on-demand thing.
There is no...hey compiler have a look at this, but don't actually compile it feature. Our parser is client side and is following the rules of the Oracle SQL and PL/SQL syntax and applies that to the code it sees.

Related

SQLDeveloper, Oracle Procedures with Error

Is there any way to know why the procedures are in error?
They compile well.
Yes it is possible in SQL Developer under "Errors" tab:
Image source: https://thatjeffsmith.wpengine.com/wp-content/uploads/2012/01/show_errors3.png
Related: Viewing PLSQL Compilation Errors in Oracle SQL Developer

Impdp ora-00904 invalid identifier

I'm triying to import our database which is in WE8MSWIN1252 instance to a new AL32UTF8 instance.
I'm using impdp tool to achieve this.
I get the following error
Processing object type
SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
ORA-39083: Object type ALTER_PACKAGE_SPEC:"MyOwner"."MyPackageOwner"
failed to create with error: ORA-00904: "DECL_OBJ#": invalid
identifier
Please note that when I compile this package using SQLplus it is working as expected
Do you have any idea about what can causes this error ?
Thanks,
Bilel
Open SQL Developer. Set the PLScope identifiers parameter (Tools > Preferences > Database > PL/SQL Compiler > PLScope identifiers) from All to None.
Close and open the SQL Developer.
It solved my issue.
In the support note mentioned above, Oracle says that this error is related to SQL Developer and a specific patched version of Oracle DB (12.2.0.1.181016).
As a workaround it seems you can disable PL/Scope (a functionality to parse and analyse PL/SQL code) like this :
Open SQL Developer Set the PLScope identifiers parameter (Tools > Preferences > Database > PL/SQL Compiler > PLScope identifiers) from All to None.
Close and open the SQL Developer
I have just excluded views, packages and package_compile from the export and this worked as expected.

Oracle Procedure Slowness (Operation Time out error)

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;

How to recompile invalid PLSQL packages that have been encrypted using Oracle 10g's Wrap utility?

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)

Why do packages and views in Oracle SQL Developer sometimes appear to have errors even when they compile?

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.

Resources