Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Issue with repeating execution of the same procedure.

Posted on 2007-11-28
9
Medium Priority
?
508 Views
Last Modified: 2013-12-19
Hi everyone,

I have an issue executing this same procedure multiple times.

Right after compilation it works fine. When I execute the same procedure second time I gets the following error message:

ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "scott.REC" has been invalidated
ORA-06508: PL/SQL: could not find program unit being called
ORA-06512: at line 5

If I run it third time (not doing anything) or explicitly recompiling it again it works. If I run it fourth time I gets the same error message from above. It seems that I have to recompile this procedure explicitly every time to avoid a system error. What could be wrong with this procedure?

Please advice.
0
Comment
Question by:GoodName
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 20371281
can you paste your procedure code please ?
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 20371291
may be your procedure is altering ( issuing some ddl ) which is invalidating this procedure.
0
 
LVL 18

Accepted Solution

by:
Jinesh Kamdar earned 800 total points
ID: 20371414
I agree with nav. Your SP must be issuing ALTER DDL statements that are referenced by the SP before/after the DDL statements which in turn invalidates the procedure itself bcoz of the dependency. Post your code.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:GoodName
ID: 20375660
Thank you both for your comments.

It is hard to post my procedure because of client security requirements and because it is a package of about 4000 lines of code.

But from what you are telling I can confirm that my package has many dynamic  queries (DDL statements like CREATE, DROP, ALTER tables) which create "on a fly" ETL staging environment (a lot of temporary and permanent tables, sequences, constraints and indexes).

In this situation what I can do to prevent this package from crashing during job executions? This package is executed only as a night job to feed a data warehouse.

Please advice.
0
 

Author Comment

by:GoodName
ID: 20378294
Hi everyone,

For now I am using DBMS_DDL.ALTER_COMPILE() utility to make a package run without this error.

But I would like to understand how I can adjust my package to avoid such situation in a first place rather then to fix it every time.

I'd appreciate any advice.

Thanks.
0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 1200 total points
ID: 20379145
If that is the case then we should have something like shown below ( just one more job -- just to compile your procedure/package before you execute it ).

job1 : -- dummy job to compile your procedure/package which is giving that error.

job2 : -- this is the job which executes your procedure. ( for sure it will not give any errors because we compile it using job1

Thanks
0
 

Author Comment

by:GoodName
ID: 20379734
Nav,

I have already created a little procedure which checks the status of the package and if it necessary compiles it before execution and it is working okay. Thank you.

But I would like to correct the package. How I can use DDL statements not turning a package status to invalid? Or it is not possible within the same package if it has references to created by DDL statements objects?

Thanks.



0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 1200 total points
ID: 20380016
By default, oracle invalidates any packages whenever you run DDL on those objects which are referenced in your package. We cannot stop this.

we can get rid of errors by compiling it before we call it.

Also let us say when some other package/procedure does some DDL ( alter to your database objects ) on which your actual package is based, then also your actual package will go invalid.

Can you execute the DDL's alone out of this package code ( is this not possible ) ?

Thanks
0
 

Author Comment

by:GoodName
ID: 20386210
Thank you, Nav.

All this recompilation is not very convenient approach to DDL functionality from Oracle.

Normally, we are trying to compile the code and save it in the cash for performance improvements (avoiding unnecessary parsings and compilations) but in this case we are enforced to..

Yes, I created another "entry level" procedure where I recompiling the ETL package prior to its execution and created a job which runs this "entry" procedure. This way, it seams more safe especially in a case if DBAs or developers need to execute the ETL process ad-hoc.

Thanks again for your help.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question