ORA-04068: existing state of packages has been discarded

I work on an order entry system that is up 24x7 running Oracle version 8.0.5. I want to compile a fix to a procedure contained in a package body. I only will be recompiling the package body. Since the package body has no dependent objects, I should not invalidate any stored procedures that call this procedure in my package. However, should I worry about causing an "ORA-04068: existing state of packages has been discarded" error? What causes this error and when does it occur?

Please ensure that DBMS_ROWID is created in SYS schema and not in any ordinary user's schema. If it exists in any user's schema drop it from there.
If the problem persists, drop the package from sys schema as well and run two script files in the following order:
1) ORACLE_HOME\rdbms\admin\dbmsutil.sql
2) ORACLE_HOME\rdbms\admin\prvtutil.plb

Similar Messages

  • Existing state of packages has been discarded...

    Hi all,
    I know this is a long shot and probably you need more details to help, but please take a look in case you've encountered something similar before... It is a pretty interesting problem.
    Ok, I have two packages, say, A and B. Package A is composed of utility functions, and package B makes use of those functions. These packages are compiled as part of the schema installation, where package A is always compiled first. I also have unit test scripts for each procedure in each package.
    Now, after schema installation, when I run the unit test for some procedures in package B, I get the following error:
    ORA-04068: existing state of packages has been discarded
    ORA-04065: not executed, altered or dropped stored procedure "my_schema.pkg_A"
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512: at "my_schema.pkg_B", line 18
    ORA-06512: at line 5
    Some interesting notes:
    - I can run the unit test of all pkg A procedures. I can also describe the package. Which seems to me that pkg A has been compiled successfully.
    - If I log into a sqlplus session, run the unit test for a pkg B procedure, which then fails with the above message. Then I run a unit test of a pkg A proceudre, which succeeds. Then I run the same pkg B unit test, it will work then. And all the other pkg B procedures will work from this point on.
    - But if I log out from sqlplus session, and log in again, and run the pkg B procedure unit test again, it will fail as before.
    - Certain procedures in pkg B have no problem running. They also call pkg A procedures. However, the pkg A procedures are always invoked in the where or order by clauses in these cases. The pkg B procedures that call pkg A procedure in a standalone statement will always fail.
    - The fact above made me suspect that function-based indexes (which were created using pkg A procedures) were used in cases where pkg B procedures work. And that in those cases pkg A hasn't really been invoked. However, when I monitor those indexes using v$object_usage, it shows they are not used. (I have a very small set of data.)
    - After schema installation, if I compile pkg B again, the problem will disappear.
    Does this ring a bell to anyone? Any help will be appreciated.
    Thanks,
    Gloria Chung

    Thanks for reading and responding.
    I'm compiling both header and body for both packages.
    I ran the following query after schema installation, which returned 0:
    select count(*) from user_objects where status='INVALID';
    The schema installation involved putting new copies of both package A and B.
    If I only recompile the package body after installation, it will still 'cure' the problem. I.e. if I run any of the affected pkg B unit test, it will run successfully.
    It is assumed there is no schema before 'schema installation'.
    Thanks,
    Gloria

  • Existing state of package has been discarded...

    If application is running and it uses cursors/prepared statements for procedures and functions in packages and
    new version of package is inserted into database, then an error message 'existing state of package has
    been discarded' is raised.
    However, there are packages where there is no 'existing state of package'. And for application purposes
    new version of this package should be used without this error message.
    Enhancement: There should be a pragma stating that package is 'stateless' and new version ot it is used if it
    exists without an error situation.
    This feature would be beneficial e.g. in 3-tier architecture where servers are running constantly.
    Or can this be accomplished with any other way (without parsing statement with every call ) ?

    When session references a package for the first time package is instantiated in session memory. If package is recompiled since, Oracle assumes it possibly changed and package instance in session memory is no longer valid. That's why any reference to that package made by such session will raise an error.
    Session 1:
    SQL> create or replace
      2  package pkg1
      3  is
      4  g_n number;
      5  procedure p1;
      6  end;
      7  /
    Package created.
    SQL> create or replace
      2  package body pkg1
      3  is
      4  procedure p1
      5  is
      6  begin
      7  for rc in (select * from emp) loop
      8  dbms_output.put_line(rc.empno);
      9  end loop;
    10  end;
    11  end;
    12  /
    Package body created.
    SQL> exec pkg1.p1;
    PL/SQL procedure successfully completed.
    SQL>This instantiated package PKG1 is session1. Then session 2:
    SQL> alter package pkg1 compile body;
    Package body altered.
    SQL> Back to session 1:
    SQL> exec pkg1.p1;
    BEGIN pkg1.p1; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "SCOTT.PKG1" has been invalidated
    ORA-04065: not executed, altered or dropped package body "SCOTT.PKG1"
    ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.PKG1"
    ORA-06512: at line 1
    SQL>SY.

  • Problem with ORA-04061: Existing state of string has been invalidated Tips

    hi,
    i'm a oracle developer and work in a IRON Industry, in our industry we have several levels of data communications, in our level 2, all of software developed on .NET platform, and in level 3 we have oracle tools such as form builder, we have a connector called ICC that developed in .Net platform, ICC gathers datas from level 2 on tcp/ip and write in a oracle database(level 3), a BEFORE INSERT trigger wrote on a table that ICC insert into it datas and calls several packages in the level 3, we have oracle database 10g R2, in this database if state of one of dependent procedures or functions that called in main package changed to INVALID then this trigger doesn't work, if any body have any suggestion to change our solution please help me.
    Thanks alot

    Arash wrote:
    hi,
    i'm a oracle developer and work in a IRON Industry, in our industry we have several levels of data communications, in our level 2, all of software developed on .NET platform, and in level 3 we have oracle tools such as form builder, we have a connector called ICC that developed in .Net platform, ICC gathers datas from level 2 on tcp/ip and write in a oracle database(level 3), a BEFORE INSERT trigger wrote on a table that ICC insert into it datas and calls several packages in the level 3, we have oracle database 10g R2, in this database if state of one of dependent procedures or functions that called in main package changed to INVALID then this trigger doesn't work, if any body have any suggestion to change our solution please help me.
    Thanks alotThis probably is not specific to your .NET application. If you can reproduce this from SQL*Plus please post this over on one of the OTN database forums, as there a lot more DBAs over there who could potentially help you.

  • ORA-4068 Existing stage of package discarded - Techniques of avoid variable

    Hi all,
    I need to ‘strip’ the state from a package (let’s say PKG_MAIN). I’ve already transform all constants into functions but I have difficulties in finding the best solution for the variables. Most of the variables are collections and I cannot use temporary tables to replace them (performance issues). As well I have tried creating a package (PKG_VARIABLES) for all variables but, as you probably know, this is not a ‘fix’ because changing the PKG_VARIABLES will trigger, when calling the PKG_MAIN, the ORA-4068 anyway.
    Any ideas??
    Cheers,
    Harada

    [standard response for package state]
    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.

  • SQL Plus session - "schema.package" has been invalidated on making any chng

    Hi
    I am in the process of testing a stored procedure. Whenever I make changes to the procedure I am executing it from the SQL Plus session. But whenever I make a change to the procedure - i have to close that particular SQL Plus session and open another one. I get the message:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-04061: existing state of has been invalidated
    ORA-04061: existing state of package body
    "schema.package" has been invalidated
    ORA-04065: not executed, altered or dropped package body
    Is there a way that I do not have to open a new SQL Plus session everytime I make change to the package?

    It does not help :(. I get this problem in a SQL+ session only when I make a change in a JDev session. I have to log off the SQL+ session and log back in and it is OK again without re-compling anything. I don't have a problem with two SQL+ session. Isn't that strange?
    ben

  • ORA-04061: existing state of  has been invalidated

    Hi,
    In Development Database Information
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE     11.2.0.2.0     Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Solution required for this oracle error
    I am getting this Error - ORA-04061: existing state of has been invalidated
    package pkg1 -> Main pkg
    pkg1 calling another package pkg2
    i am modified and recompiled the package pkg2.
    After executing the package PKG1 it throwing this Error ORA-04061.
    i am checking user_objects and it status are VALID.
    In both package doesnt have the any variables.
    Please suggest the above issue.
    Thanks in advance.
    Regards,
    Sudhakar P

    BluShadow wrote:
    Karthick_Arp wrote:
    Sudhakar P wrote:
    Hi,
    how to reload it into memory - SGA ?.Please suggest me.
    Regards
    Sudhakar P.I guess you dint get my point. So may be read this {message:id=3488533}:) Saves me re-posting it.Still remember reading it way back then :). I much appreciate the time you spend on explaining it in detail.

  • Existing state of package discarded

    Hi,
    How can i avoid the error "Existing state of package discarded.." error.. my package is called from java front end and it gives error in front end. once, i refresh the page it starts working...
    Thanks,
    JP

    This is caused by having package level variables in your package and then something that the package depends (dependencies) are changing in some way which invalidates the package.
    If there are no package level variables then the package will automatically re-compile and be usable, but if there are package level variables then these are considered to be the "state" variables for that users session. When the package becomes invalidated for whatever reason, then it is basically saying "I can't recompile the package because you will lose the state of your copy of the variables" which is why the error is generated, and once you have been given the error, if you access it again it will cause it to recompile anyway.
    One solution is to remove all package level variables (and constants) to a seperate package spec and alter the code of the package to reference them in that package spec.
    ;)

  • How to check the last time a package has been compiled?

    How to check the last time a package has been compiled from sqlplus?

    LAST_DDL_TIME column in DBA_OBJECTS.

  • My broadband package has been downgraded without m...

    I wrote on here a couple of days ago as I was really annoyed at BT for cancelling my order for the Home Hub 4 which they ordered on my behalf - the order has disappeared off the MY BT page and I've no idea what happened, can only speculate. However, I've now logged back into My BT and found my broadband package has been downgraded from Unlimited Broadband to More Broadband!!! As far as I can tell, this means I've now got a limit of 40GB per month - I use that in a week!!
    What the hell are BT playing at? Has anyone got these problems or have I been landed with the idiots??
    Seriously considering cancelling the contract even though we are only weeks into it.
    Sort it out BT

    Hi
    I am sorry to see you are having problems
    I suggest you contact live chat at this link they should be able to help you
    http://bt.custhelp.com/app/contact/c/2902/?s_intcid=con_intban_sanda_contact_us_chat_from_forums
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Not encrypted dot1x packet from 0012.f0b9.87c3 has been discarded

    I have a very basic config to setup wireless on on an 857W router.
    When I get connected the log fills up the the following message.
    Not encrypted dot1x packet from 0012.f0b9.87c3 has been discarded
    What is causing this?
    Config below
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname Router
    boot-start-marker
    boot-end-marker
    no aaa new-model
    dot11 ssid TESTSSID_1
    vlan 10
    max-associations 10
    authentication open
    authentication key-management wpa
    wpa-psk ascii 0 mywpapskpwd
    dot11 ssid TESTSSID_2
    vlan 20
    max-associations 10
    authentication open
    authentication key-management wpa
    wpa-psk ascii 0 mytestpassword
    no ip dhcp use vrf connected
    ip dhcp excluded-address 192.168.100.1
    ip dhcp pool HOME_1
    network 192.168.100.0 255.255.255.0
    default-router 192.168.100.1
    ip dhcp pool HOME_2
    network 10.20.0.0 255.255.255.0
    default-router 10.20.0.3
    ip cef
    archive
    log config
    hidekeys
    bridge irb
    interface ATM0
    no ip address
    shutdown
    no atm ilmi-keepalive
    dsl operating-mode auto
    interface FastEthernet0
    interface FastEthernet1
    spanning-tree portfast
    interface FastEthernet2
    spanning-tree portfast
    interface FastEthernet3
    interface Dot11Radio0
    no ip address
    no ip route-cache cef
    no ip route-cache
    encryption vlan 10 mode ciphers tkip
    encryption vlan 20 mode ciphers tkip
    broadcast-key change 60
    ssid TESTSSID_1
    ssid TESTSSID_2
    speed basic-1.0 basic-2.0 basic-5.5 basic-6.0 basic-9.0 basic-11.0 basic-12.0 basic-18.0 basic-24.0 basic-36.0 basic-48.0 basic-54.0
    channel 2452
    station-role root
    world-mode dot11d country GB both
    no cdp enable
    bridge-group 1
    bridge-group 1 subscriber-loop-control
    bridge-group 1 spanning-disabled
    bridge-group 1 block-unknown-source
    no bridge-group 1 source-learning
    no bridge-group 1 unicast-flooding
    interface Dot11Radio0.10
    encapsulation dot1Q 10 native
    no ip route-cache
    bridge-group 10
    bridge-group 10 subscriber-loop-control
    bridge-group 10 spanning-disabled
    bridge-group 10 block-unknown-source
    no bridge-group 10 source-learning
    no bridge-group 10 unicast-flooding
    interface Dot11Radio0.20
    encapsulation dot1Q 20
    no ip route-cache
    bridge-group 20
    bridge-group 20 subscriber-loop-control
    bridge-group 20 spanning-disabled
    bridge-group 20 block-unknown-source
    no bridge-group 20 source-learning
    no bridge-group 20 unicast-flooding
    interface Vlan1
    ip address 10.7.12.219 255.255.255.0
    interface Vlan10
    no ip address
    ip virtual-reassembly
    ip tcp adjust-mss 1400
    bridge-group 10
    hold-queue 100 out
    interface Vlan20
    no ip address
    ip virtual-reassembly
    ip tcp adjust-mss 1400
    bridge-group 20
    hold-queue 100 out
    interface BVI10
    ip address 192.168.100.1 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    interface BVI20
    ip address 10.20.0.3 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    ip forward-protocol nd
    ip route 0.0.0.0 0.0.0.0 10.7.12.254
    no ip http server
    no ip http secure-server
    control-plane
    bridge 10 protocol ieee
    bridge 10 route ip
    bridge 20 protocol ieee
    bridge 20 route ip
    line con 0
    no modem enable
    line aux 0
    line vty 0 4
    login
    scheduler max-task-time 5000
    end
    Router#

    Too funny... I get clients complain to me about issues and they have drivers that are from 2003 or 2004.
    Now all you have to do is make sure all other devices are on the same firmware. Makes troubleshooting sooooooo much easier.

  • My apple I'd has been discarded for security reasons. The site asks me to give my email and they would send me the further instruction. But no Emil has arrived so far. Since January. And I did requested help multiple times. :( any ideas where can I solve

    My apple I'd has been discarded for security reasons. The site asks me to give my email and they would send me the further instruction. But no Emil has arrived so far. Since January. And I did requested help multiple times. :( any ideas where can I solve

    Who discarded the Apple ID? Apple? or You?
    Did you answer the Security Questions? Is the backup email accurate? Have you tried contacting them?

  • States eprint job has been received but never prints but will print my daily comics.

    ok, my printer will not print my pics from my phone, but has before. I send the pic to the printer, my email states that the eprint has been received but the printer never comes through to print. I looked on the HP site and it stated that the eprint had failed, does not explain why and I cant contact anyone to ask for tech support. I have my printer set up to print my daily comics, that it has no problems printing. I have printed off several pics from my phone off this printer, however after the first few days the printer decided what it wanted to print. Some would come through and some wouldn't.  Also I put in a memory card from a camera to print pics and it refuses to read it, any memory card. I have even tried the memory card from my phone in an adapter and it still will not read. Please if anyone knows how to correct these problems please help me!? Im really thinking about returning this printer.  Thank you

    Did you get your problem solved?
    If not, I may be able to bring it to the attention of someone that could help you.
    I work on behalf of HP.

  • Iphoto 9.4.2 states facebook album has been deleted

    When I try to upload fotos to Facebook the upload stops/crashes and then I receive a message stating that some random facebook album has been deleted. hen I check the photos remain but the upload is now stopped and I must redo.
    Is there a fix?

    Thanks LN.
    I tried.  It would not download.  A drop down notice said an error had occurred and to return to the purchase page; which I have done on numerous occasions.  (What I am to do on the purchase page I am not sure, other than to click on purchases and see that the same iPhoto download is available.  By the way, this was not purchased.  It just showed up with two other items free items, which did download nicely.)
    Otto

  • Am having a problem locating autocad lt 2012 edition on mac app store. anyone had any success with this. all the websites state that it has been launched on mac app store last week

    has anyone been able to purchase the autocad 2012 lt edition that apparently is available on mac app store. dont seem to be able to find it?

    This article was posted on August 16th: http://blogs.wsj.com/digits/2011/08/16/autodesk-adopts-apple-app-store-for-mac-s oftware/
    Perhaps this coming Tuesday.

Maybe you are looking for