Valid packages goes invalid when executing application

Friends of pl/sql
When we execute our application we find that 2 of our main packiages go invalid for no reason. The packages compiles just fine when we then compile them. So, no syntax errors. But it stops our application with a lovely "existing state of packages have been discarded......." type error. Not too nice.
What are some of the things to check on for why the package goes invalid ?
We are using TOAD and sql*monitor to trace the process at the moment...........
Any solutions out there ?
Environment : Oracle Enterprise Linux 5 on Oracle 11.1.0.6 (latest patch available). Oracle 11 client as well.
Edited by: ow001294 on Apr 15, 2009 9:24 AM

One of my older standard responses (haven't use this in a while)..
Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
And if you want to know how to prevent discarded package states....
Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
  2  /
Table created.
SQL>
SQL> insert into dependonme values (5)
  2  /
1 row created.
SQL>
SQL> create or replace package mypkg is
  2    procedure myproc;
  3  end mypkg;
  4  /
Package created.
SQL>
SQL> create or replace package body mypkg is
  2    v_statevar number := 5; -- this means my package has a state
  3
  4    procedure myproc is
  5      myval number;
  6    begin
  7      select x
  8      into myval
  9      from dependonme;
10
11      myval := myval * v_statevar;
12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13    end;
14  end mypkg;
15  /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALID
SQL>
SQL>
SQL> alter table dependonme add (y number)
  2  /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
BEGIN mypkg.myproc; END;
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
ORA-06512: at line 1
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
SQL> drop table dependonme
  2  /
Table dropped.
SQL>
SQL> drop package mypkg
  2  /
Package dropped.
SQL>
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
  2  /
Table created.
SQL>
SQL> insert into dependonme values (5)
  2  /
1 row created.
SQL>
SQL> create or replace package mypkg is
  2    procedure myproc;
  3  end mypkg;
  4  /
Package created.
SQL>
SQL> create or replace package mypkg_state is
  2    v_statevar number := 5; -- package state in seperate package spec
  3  end mypkg_state;
  4  /
Package created.
SQL>
SQL> create or replace package body mypkg is
  2    -- this package has no state area
  3
  4    procedure myproc is
  5      myval number;
  6    begin
  7      select x
  8      into myval
  9      from dependonme;
10
11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13    end;
14  end mypkg;
15  /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALID
SQL>
SQL> alter table dependonme add (y number)
  2  /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.

Similar Messages

  • RuntimeException when executing application mapping program

    Dear Friends
    I am trying to send an Idoc from R3 system to an SCMTM system.
    I have imported the idoc, message mapping is preconfigured from SAP and requisite  configurations in ID have been completed.
    I am getting this error in test of Interface mapping (operation mapping).
    RuntimeException when executing application mapping program com/sap/xi/tf/_DESADVDELVRY03_to_ShipmentRequestRequest_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns0:ShipmentRequestRequest. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD.
    Please help.
    Thank You
    Warm Regards
    Arjun Ghose

    Hi,
    it seems that per your XSD the element "/ns0:ShipmentRequestRequest" needs to be created and filled with a value (occurance min 1). But appearently within your mapping you do not create or fill this element. So the validation of the XML against the XSD fails.
    Please check your mapping regarding the element "/ns0:ShipmentRequestRequest".
    Reagrds,
    Kai

  • DBMS_JOB using Packaged Functions but Package goes invalid

    Is there any way to check a package while running a PL/SQL procedure to see if it's state is valid and then catch the exception?
    In my case usually just calling any function in the package 1x clears it up but the procedure in question runs as a DBMS_JOB it just keeps failing. This procedure could run often enough that Oracle will mark it as broken but I want to give it every shot at execution on time instead of having to make it wait till the next cycle.
    What I would like to do is to catch the exception for the package state being invalid and basically have it go back to the beginning of the procedure and give it another try before failing in case it is just a failure because the package has been altered.
    Is there any way to do this?

    Firstly, I'll copy/paste my standard response regarding package state going invalid as it usually helps to have an understanding of these things...
    Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
    If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
    And if you want to know how to prevent discarded package states....
    Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
    As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
    This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    v_statevar number := 5; -- this means my package has a state
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * v_statevar;
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    BEGIN mypkg.myproc; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
    ORA-06512: at line 1
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
    SQL> drop table dependonme
      2  /
    Table dropped.
    SQL>
    SQL> drop package mypkg
      2  /
    Package dropped.
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package mypkg_state is
      2    v_statevar number := 5; -- package state in seperate package spec
      3  end mypkg_state;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    -- this package has no state area
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.---------------------------------------------------------------------------------------------
    Secondly, from this above standard response, you can see how to check for package state if you want to determine it programatically.
    ;)

  • Package giving error when executed through bat file

    The packages successfully execute in SQL Server Data Tools but when I use DTEXEC to execute it gives me the following error:
    "To run a SSIS package outside of SQL Server Data Tools you must install Send Mail Task of Integration Services or higher .
    I tried 5 different packages and all of them showed similar error except the send mail task is replaced by different other tasks of those packages.

    Go to start-> run
    Type Services.msc. It will launch services window.
    Check for a service named SQL Server Integration Services with or without version number. If its present it means SSIS is installed. Also make sure its started and is in running state.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Package file invalid when installing on Motorola Razr i

    I have tried several times to install the app on my Razr i but it always says that the package file is invalid

    Hi Ignacio!
    Same problem, on same phone!
    The Motorola Razr I has Intel Medfield X86 architecture. Different architecture of ARM Processor
    Motorola Razr i - XT-890 (Android 4.0.4 or 4.1.2) is sold on Europe and Latam
    Thanks,
    Thiago

  • TS3212 trying to activate my iPhone 4S when I try to download iTunes on my Windows 7 computer I keep getting  message telling me to verify that the package exists or contact the application vendor. All I want to do is activate my new phone. What am I doin

    I was excited when my iPhone 4sarrived yesterday. I charged it but today when I tried to download iTunes in order to activate the phone I found that I was unable to download it successfully. I keep getting a message that tells me to Verify that the package exists or contact the application vendor. I have no idea how to do any of this. I was downloading from the AT&T support site.

    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/quicktime/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • SharePoint Error "The security validation for this page is invalid" when delete an item

    Hi,
    I have SharePoint 2010 setup and works fine until today all of a sudden it throws error "The security validation for this page is invalid" when delete a SharePoint document or list item.
    There is no custom event handler deployed on library/list, and it should not be account issue as the same account works yesterday, and even after I turn off security validation from Central Admin, it still doesn't work.
    The only change I did is turn off Dynamic Compression from IIS, after that I tried enable back Dynamic Compression but it still doesn't work.
    Does anyone know what could be the possible reasons? Thanks in advance.

    hi,
     in the page just try to make this :
    <SharePoint:FormDigest runat="server" />
    PrasadWT

  • Error with Project Parameters when executing the package with dtexec command

    Hi,
    We have started migrating our SSIS package from 2005 version to SSIS 2012. In SSIS 2005 we were using XML configuration files and executing the packages with dtexec command from the packages folder (without deploying packages to filesystem).
    Now in SSIS 2012, we have seen Project Parameters and created couple of package parameters and used those parameters in the package. when executing this package from solution explorer it was working fine but when i try to execute the same package from command
    line with Dtexec command, it was showing an error message of 'Not able to map Project Prameters to configurations'.
    Could you please give me an idea of how to execute the packages from command line by using dtexex command. basically i would like use project parameters in 2012 similar to configurations?
    Thanks,
    Venu.

    Refer
    http://msdn.microsoft.com/en-IN/library/hh231187.aspx
    you can pass parameter like this
    /SET \Package.Variables[$Package::ParameterName];<value> /SET \Package.Variables[$Project::ParameterName];<value>
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Security code comes up invalid when in fact it is very much valid

    Recently when trying to download apps it prompts me to sign in and view my billing info. All the information is correct including my security code. I have taken it out and put it back in and yet it still says my security code is invalid when it 100% is not. So frustrating! Please if someone could tell me what the crap is going on I would be so thankful!!

    This can only be resolved by iTS.
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Error when executing planning application in Web

    Hi everyone,
    When executing a planning function in BEx Web, via Web Application Designer, I am getting the following error message.
    ABEND BRAIN (178): Common entries are not permitted for plan queries and input queries
    MSGV1: Aggregation level name
    Where do I go wrong?
    Thanks in advance, hope this is enough info.

    Have you considered creating a characteristic relationship with an EXIT Class. In this way you are able to make the value whatever you want according to the rules you code.

  • Installed Photoshop Elements 13.  Upon activation, get through sign in screen, but when doing serial number validation, validate goes round but does not validate.  Connect Later is only way out of screen.  How do I validate.  Checked account but product n

    How do one validate Photoshop 13. (Windows 8) Upon activation, get through to sign in screen, but when doing serial number validation, validate goes round but does not validate.  Connect Later is only way out of screen.  Checked account but product not listed.  Installed with serial number that was sent  by Adobe.  Have attempted numerous times at different times of the day.  On-line connection working.

    Have you bothered to do any research at all? Not every app was upgrade to 5.5. Those that weren’t will next be upgraded to CS6.
    Bob

  • When I Try to Repair Permissions I Get a No Valid Packages Message

    When I try to repair the disk permissions on my startup disk I get a message that states no valid packages. This happens wether I repair or verify or wether im booted into Mac OS X or the Install Disc.
    If anyone has any suggestions please feel free to answer.
    Thanks!
    Matt

    Hi Mr. Macintosh693
    Perhaps you have thrown out some needed files.
    This article should help.
    http://docs.info.apple.com/article.html?artnum=25704
    regards roam

  • Applescript in Automator behaves differently when executed from inside Automator, or as an Automator application

    Hello everyone,
    I'm trying to execute an Automator workflow at startup, which I do by saving the workflow as an application, and adding it to the startup list, this works fine.
    My workflow works fine when executed from within Automator (ie clicking on the "Execute" button), but does not anymore when the Automator application is executed (ie. simply double clicking on my Automator file)
    I have narrowed it down to an Applescript inside my workflow which fails only when the application is executed from the finder (the step works fine from within Automator). The script automatically creates an ad hoc wifi network.
    The line which specifically fails is :
    set menu_extras to value of attribute "AXDescription" of menu bar items
    Anyone has any idea why executing the workflow from within automator, and executing it from the finder yield different results ?
    The crazy thing is that all this worked fine up until a few days ago, there might have been an update since (running Mavericks 10.9.2), but nothing game-changing.

    You will need to provide more than the one line of AppleScript you quote if you want a definitive answer.  (We can't even see which app you are addressing this to.)

  • HT1539 iTunes says the code is invalid when it clearly is valid, what do I do? How do I get my digital copy??

    I bought The Dark Knight a few years ago, I tried to download the digital copy before but I gave up. Now that I have my iPhone, I'm determined to get all the digital copies I'm entitled to! So I'm here to find out how to remedy the situation. iTunes says the code is invalid when it clearly should work. I didn't buy the DVD off the street or anything. iTunes doesn't give me any further options, so what can I do? Anybody have any advice, please?

    Yeah, I actually did get it. I had to send an e-mail to Warner Bros. with all available info and my issue and they sent me another code that actually worked.
    So I actually just had to do what varjak paw suggested, it just took a few days (maybe a week) and I forgot to get back to you guys. So, belated but all the same thank you, varjak paw!

  • My Macbook display changes color when I open applications. It looks like there is a light blue layer over the screen, thus changing the color of my display. This layer goes away when i quit the applications.

    I am facing a problem and I am not sure if its a graphic card malfunction. When I open applications like Chrome, VLC player, and most apps, my display suddenly changes color. It is as though the Theme was changed. The normal grey panel on opened windows turns to light blue and everything else seem as though there is a light blue layer on top of it. When I close these applications (quit) the display returns to its normal self.
    My MacBook Pro is 2 years old, and I have an extended warranty. Will Apple replace my graphic card if it is actuall the graphic card's problem?

    I had that problem, too, and it's been documented both here and on the Adobe forums. What happens is that when you have dynamic switching on, when an application that uses your discrete GPU kicks in, the screen will change color. My problem lasted for a couple of weeks then just vanished.
    What you need to do is download Cody Krieger's gfxCardStatus and turn off dynamic switching and leave your GPU set to discrete only. That's the only fix that I know of at this time. I don't know why it happens or why mine stopped.
    Good luck,
    Clinton

Maybe you are looking for

  • Infoset functionality in BI-HR

    HI all, I worked on infoset, but functionality of Infoset with time dependent objects is different. Can any one share there experience with infoset scenarios in HR module implementations. 0HR_PA_0 and 0HR_PA_1 doesn't support delta , then how to capt

  • Manual Migration

    A bit of a philosophical question, perhaps, possibly to be filed under "old dog can't learn new tricks", but I've gone through seven Macs and more OS radical updates I care to count in some 25 years, we thought going from OS 6 to the famed "System 7"

  • OpenJPA error

    I am getting these errors for JPA . We are actually using OpenJPA 1.1.2 on eclipse but it still shows Open JPA1.1.1 in error . Also is there something wrong in query/code ? DaoException: <openjpa-1.1.1-SNAPSHOT-r422266:807362 nonfatal user error> org

  • General Problems Installing Flash Player

    I'm trying to get movies to work on Youtube (which worked yetserday; was the new version added recently?). It told me to download the newest Flash Player, so I tried to, but it doesn't work. I can get up to the step after the activeX control popup an

  • CKM3 in mass

    Hi people, We would like to have the transaction CKM3 in mass (many materials). I know there are some SAP Note to apply to get the program, but at this moment I couldn´t find. Could you help me please? Thanks, Rosana.