Handle ORA-04068 invalidated package

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
amoroder
Posts: 30
Joined: Sun 12 Sep 2010 11:33

Handle ORA-04068 invalidated package

Post by amoroder » Wed 11 Feb 2015 14:47

Hello,

in many places of our code we have selects that call a function in a package.
when we recompile the package the users get a error message of the type

ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package "XXX.TEST_PKG"
has been invalidated
ORA-04065: not executed, altered or
dropped package "XXX.TEST_PKG"

My solution is to put the assignmend of the Sql statment, the variables, the prepare and the activate in a loop with a try except, check if the error Message contains ORA-04068 and repeat the loop one time. On the error oracle resets the package status and the next loop it works.

It is a lot of work to do this in all the places where this pacakge function is called.
Is there a way to tell ODAC to retry himself one time if this error occurs ?

This would be a very nice feature

Thanks
Andreas

Thanks
Andreas

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Handle ORA-04068 invalidated package

Post by AlexP » Thu 12 Feb 2015 10:56

Hello,

To handle all the errors (that occur in all the ODAC components), you can use the onError event, in which you can check the error code and ignore this error.

Code: Select all

procedure TForm1.OraSession1Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
  case E.ErrorCode of
    4061, 4065, 4068: Fail := False;
    else Fail := True;
  end;
end;

Post Reply