DBMS_SESSION.RESET_SELF() + ORA-04068

Hi all,
as I was looking through the new features guide of 11.2 release I ran across
the following section which raised my interest:
2.1.1.5 Improvements to Reduce the Occurrences of "Existing State of Packages
Discarded" Errors
When the body of a stateful package is recompiled by session A, then a
different session B which has already instantiated that package will
experience the ORA-04068 existing state of packages… has been discarded family
of errors on its next reference to that package following the recompilation.
The result is severe disruption for the user of session B.
Two improvements in this release now reduce the likelihood of these ORA-04068
errors:
* A package, whose global variables is marked constant; and where the
initial value can be computed at compile time, is now considered to be
stateless.
* The new procedure DBMS_SESSION.RESET_SELF(), whose invocation must
be in the package of interest, allows you to preempt the problem when it is
safe to reinitialize the package state.
The advantage is that packages (and especially those that are not editioned)
can be "hot patched" (that is, recompiled) when other sessions are using them
with a greatly reduced likelihood of disrupting those sessions.
As I wanted to try out the DBMS_SESSION.RESET_SELF() procedure I did not find
it in the dbms_session package ? There is also no documentation in the Types
and Packages book. Any hints ? Do I miss something ?
Very best regards
Michael

Can you please post a URL to that doc ref?
Also had a look and there's no trace of this call (11gr2). Searched the contents of +$ORACLE_HOME/rdbms/admin+ for the keywork reset_self and no hits.
Metalink note +PACKAGE DBMS_SESSION Specification [ID 67594.1]+ also does not list this call.
Keen on this type of feature myself - I have 24x7 code running and its a pain to interrupt this, shut it down, in order to perform a basic package update (where interface spec remains unchanged).

Similar Messages

  • ORA-04068 on 11g RAC does not resolve automatically !

    Did you ever get the combination of these three ORAs?
    ORA-04068: Existing state of package has been discarded
    ORA-04065: Not executed, altered or dropped stored procedure <PROCEDURE_NAME>
    ORA-06508: PL/SQL: Could not find program unit being called: <PROCEDURE_NAME>
    *1st I checked for invalid objects in the database, there are none!*
    *2nd Then I checked the metalink note 1058873.1 that describes a similar error:*
    In hecheck output, we see that the objects affected are listed as "Dependency$ p_timestamp > > mismatch for VALID objects".
    Also, the following script can be used for finding the mismatches:
    set pagesize 10000
    column d_name format a20
    column p_name format a20
    select do.obj# d_obj,do.name d_name, do.type# d_type,
    po.obj# p_obj,po.name p_name,
    to_char(p_timestamp,'DD-MON-YYYY HH24:MI:SS') "P_Timestamp",
    to_char(po.stime ,'DD-MON-YYYY HH24:MI:SS') "STIME",
    decode(sign(po.stime-p_timestamp),0,'SAME','*DIFFER*') X
    from sys.obj$ do, sys.dependency$ d, sys.obj$ po
    where P_OBJ#=po.obj#(+)
    and D_OBJ#=do.obj#
    and do.status=1 /*dependent is valid*/
    and po.status=1 /*parent is valid*/
    and po.stime!=p_timestamp /*parent timestamp not match*/
    order by 2,1;However, the query returned 0 rows.
    *3rd Then I read about similar errors on http://oraclequirks.blogspot.com/2007/03/ora-04061-existing-state-of-package-has.html*
    The article describes the state of package being invalidated when one user calls a procedure in a package that has a global variable and changes the value of the global variable and then when a developer compiles that package, another user will get the error ORA-04061: existing state of package has been invalidated the first time he calls the procedure, but the second time it will work without returning errors.
    However, my error is persistant and Oracle can't resolve it automatically.
    Here's how the error occurs:
    - I have a PACKAGE that has a global variable and procedures
    - User1 connects to Instance1 and calls a procedure inside the PACKAGE. The procedure sets the value of the global variable by calling a function outside the package.
    For example: L_GLOBAL_VAR := OUTSIDE_FUNCTION(30);
    - The developer compiles the PACKAGE
    - User1 can continue working normaly - he receives the 1st error by Oracle informing him that the value of the global variable has changed (normal behaviour), but the second time he calls the procedure inside the PACKAGE, no errors are reported.
    - User2 connects to the second instance of the RAC (Instance2)
    - When User2 tries to call the same procedure, he constantly gets ORA errors (ORA-04068, ORA-04065, ORA-06508), like this:
    ORA-04068: Existing state of package has been discarded
    ORA-04065: Not executed, altered or dropped stored procedure "OUTSIDE_FUNCTION"
    ORA-06508: PL/SQL: Could not find program unit being called: "OUTSIDE_FUNCTION"
    ORA-06512: at "PACKAGE2", line 1920
    ORA-06512: at "PACKAGE2", line 265The PACKAGE2 has a procedure which is being called at line 265, and that procedure calls the function OUTSIDE_FUNCTION at line 1920.
    Symptoms:
    - User2 cannot correct the error by repeatingly calling the PACKAGE procedure.
    - The developer cannot resolve the issue by recompiling the PACKAGE.
    - The developer can only temporarily resolve the issue by recompiling the OUTSIDE_FUNCTION. After doing it, the User2 does not receive errors. However, if the User2 reconnects, the error returns.
    - The solution is to recompile the PACKAGE2. After doing it, the User2 does not receive errors.
    However, I'm totally confused by this Oracle behaviour.
    I told the developers that they shouldn't compile packages while there are users working on the database (a possible solution), but as a developer I know that is very very hard on a 24/7 production database, especially if there are some urgent bugs to resolve etc.
    We were working on a single instance Oracle 9i database before upgrading to Oracle 11g RAC (11.2.0.1.0), and we never had similar problems.
    I would be very grateful for any suggestions regarding this issue.
    Thanks,
    Daniel

    Hi P. Forstmann,
    Thanks for your answer. I've read about the edition based redefinition but if I understand it correctly, that's not exactly what I'm looking for.
    For example, if a connected user reports a bug that prevents her from doing her work, the developers should resolve that bug ASAP and recompile the objects in question, which should affect the connected users.

  • Webservice based on PL/SQL function - ORA-04068

    Hi,
    we have a problem here with PL/SQL based webservices. If the PL/SQL package gets invalid then the very first request to the webservice results in:
    java.sql.SQLException:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package "TUG_NEW.WBSERVICES" has been invalidated
    ORA-04065: not executed, altered or dropped package "TUG_NEW.WBSERVICES"
    ORA-06508: PL/SQL: could not find program unit being called ORA-06512: at line 1
    Any workarounds? Shouldn't the package become recompiled automatically when it was invalid?
    Thanks, Christian

    the caller gets an error on the first request. from the second request on it works ... indicates the package is not yet recompiled when the first request is sent. When the second request is sent, the package has been recompiled.

  • Continous ORA-04068 con VALID package

    Hi,
    At a customer's site we are facing a flood of ORA-04068 errors on a valid pl/sql package.
    The package is valid and so are all his dependencies.
    The db version in 10.2.0.4 on windows platform.
    It is the same situation described in metalink note #835792.1:
    - the pl/sql package involved in the error message and all his dependencies are valid.
    - the db is 10.2.0.4 so it should have the fix for bug 6136074
    I've followed the workaround described in the note which is:
    - running this sql
    select do.obj# d_obj,do.name d_name, do.type# d_type,
    po.obj# p_obj,po.name p_name,
    to_char(p_timestamp,'DD-MON-YYYY HH24:MI:SS') "P_Timestamp",
    to_char(po.stime ,'DD-MON-YYYY HH24:MI:SS') "STIME",
    decode(sign(po.stime-p_timestamp),0,'SAME','*DIFFER*') X
    from sys.obj$ do, sys.dependency$ d, sys.obj$ po
    where P_OBJ#=po.obj#(+)
    and D_OBJ#=do.obj#
    and do.status=1 /*dependent is valid*/
    and po.status=1 /*parent is valid*/
    and po.stime!=p_timestamp /*parent timestamp not match*/
    order by 2,1;
    - in the output check if there are synonyms: there was indeed a synonym pointing to the offending package
    I thought I 've found the problem
    so I dropped and recreated the synonym (as indicated).
    for a while the system runs but after some hours the error come up again.
    What else can I do ?
    Thanks
    Bye
    Nicola

    I've tried and it works for 80% of the cases.
    Unfortunately it gives the error:
    ORA-06534 cannot access serially reusable package.
    when called from a pl/sql anonymous block
    This is very annoying. This package hasn't a state at all. It only contains constants in the body...

  • Apex, ORA-04068 and pragma SERIALLY_REUSABLE

    Hi there,
    (Apex 4.0.2 and Oracle 11g)
    What are your views on using PRAGMA SERIALLY_REUSABLE on application packages called by Apex?
    It is not very clear to me the implications this would have and the performance gains it could yield, but reading the technical documentation it seems perfect for the sessionless nature of Apex.
    In a more complex scenario, what about using it in packages called by Apex via a web service?
    Now and then we get ORA-04068 after deployments and that pragma could help, that is why I started looking into it. In a "normal" (e.g. client/server) application it could have serious side effects but it seems harmless for Apex apps.
    Any comments are welcome.
    Thanks
    Luis

    Hi Luis ;-)
    I was thinking the same thing a while ago, but when I read up on it I came to the conclusion that defining packages as serially reusable for Apex would probably degrade performance.
    I have no metrics on this, nor am I sure how to measure it. I'd be curious if others have feedback.
    Scott

  • Invalidated Packages ORA-04068

    I'm using 7.0 sp2 with Oracle 9.2.0.2 thin driver and am frequently getting the
    below exception. Typcially I will run a unit test (junit), find a problem with
    an Oracle package, fix it and then rerun without bouncing WebLogic. In previous
    versions this worked fine.
    Typically Oracle gives you get this message when you are holding onto a reference
    to an Oracle object (stored proc, etc.) that Oracle has invalidated due to a change
    you have made. For example, if you have an open cursor you would be forced to
    close and reopen.
    My guess was that now WebLogic is caching some of the statements this was causing
    the problem so I set the preparedstatementcachesize to 0 but it has not helped.
    This has been slowing my development as now I have to either retry N times (N
    varies) until the problem goes away or bounce the server after each Oracle change.
    Any help would be appreciated. Thanks.
    <JDBCConnectionPool ConnLeakProfilingEnabled="true"
    DriverName="oracle.jdbc.driver.OracleDriver" MaxCapacity="10"
    Name="TuscanyJDBCPool" PreparedStatementCacheSize="0"
    Properties="user=tuscany;password=qqq;dll=ocijdbc8;protocol=thin"
    RefreshMinutes="5" Targets="myserver" TestTableName="dual" URL="jdbc:oracle:thin:@foxlau36:1521:ITVD3"/>
    <JDBCTxDataSource EnableTwoPhaseCommit="false"
    JNDIName="TuscanyJtsDataSource" Name="TuscanyJtsDataSource"
    PoolName="TuscanyJDBCPool" RowPrefetchEnabled="true" Targets="myserver"/>
    java.lang.RuntimeException: ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "TUSCANY.TITLE_INSTALLMENT" has been
    invalidated

    After talking with BEA support it looks like this is an Oracle issue. Any open
    connection in the pool that has made a such a call will be marked as invalid by
    Oracle. To get rid of the invalid connections you can reset the connection pool
    (or bounce the server).
    java weblogic.Admin -url t3://localhost:7001 -username %WLS_USER% -password %WLS_PW%
    RESET_POOL poolname
    Oracle suggests catching the exception ard retrying.
    Thanks.
    "Paul Krinsky" <[email protected]> wrote:
    >
    I'm using 7.0 sp2 with Oracle 9.2.0.2 thin driver and am frequently getting
    the
    below exception. Typcially I will run a unit test (junit), find a problem
    with
    an Oracle package, fix it and then rerun without bouncing WebLogic. In
    previous
    versions this worked fine.
    Typically Oracle gives you get this message when you are holding onto
    a reference
    to an Oracle object (stored proc, etc.) that Oracle has invalidated due
    to a change
    you have made. For example, if you have an open cursor you would be forced
    to
    close and reopen.
    My guess was that now WebLogic is caching some of the statements this
    was causing
    the problem so I set the preparedstatementcachesize to 0 but it has not
    helped.
    This has been slowing my development as now I have to either retry N
    times (N
    varies) until the problem goes away or bounce the server after each Oracle
    change.
    Any help would be appreciated. Thanks.
    <JDBCConnectionPool ConnLeakProfilingEnabled="true"
    DriverName="oracle.jdbc.driver.OracleDriver" MaxCapacity="10"
    Name="TuscanyJDBCPool" PreparedStatementCacheSize="0"
    Properties="user=tuscany;password=qqq;dll=ocijdbc8;protocol=thin"
    RefreshMinutes="5" Targets="myserver" TestTableName="dual" URL="jdbc:oracle:thin:@foxlau36:1521:ITVD3"/>
    <JDBCTxDataSource EnableTwoPhaseCommit="false"
    JNDIName="TuscanyJtsDataSource" Name="TuscanyJtsDataSource"
    PoolName="TuscanyJDBCPool" RowPrefetchEnabled="true" Targets="myserver"/>
    java.lang.RuntimeException: ORA-04068: existing state of packages has
    been discarded
    ORA-04061: existing state of package body "TUSCANY.TITLE_INSTALLMENT"
    has been
    invalidated

  • 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

  • ORA-04068

    Hello Guys,
    When i run the same form in client server environment from any machine its working fine. The same form when it is run through 9iAS on web its gives error ORA-04048. I have study the error it says that plackages used in the form need to be complied, I have already compiled each and every package and it is in valid state.
    Still getting this error, Please help.
    Regards, Imran Baig

    ORA-04068: existing state of packagesstringstringstring has been discarded
    Cause: One of errors 4060 - 4067 when attempt to execute a stored procedure.
    Action: Try again after proper re-initialization of any application's state.
    ORA-04060: insufficient privileges to execute string
    Cause: Attempt to execute a stored procedure without sufficient privileges.
    Action: Get necessary privileges.
    ORA-04067: not executed, string does not exist
    Cause: Attempt to execute a non-existent stored procedure.
    Action: Make sure that a correct name is given.
    Check it.
    listen to all other members.

  • ORA-06508 WHEN ALL PACKAGES EXISTS AND ARE "VALID" !!!

    Oracle 8i
    In a production release, I must change a central package (spec and body), which is used by some other packages.
    As a result, after the compile, the concerned packages are all marked as invalid.
    Now, we need to recompile all the invalid packages.
    As a final result:
    - all objects (packages, packages body, views, ...) exist
    - all objects are VALID
    BUT the application doesn't work !!!
    In some process, we receive an ORA-06508 error messages.
    Can someone tell me if he has the same problem ?
    Is it a Oracle bug ?
    I was thinking that when all objects are VALID and existing and compatible then an ORA-06508 should not be ?
    Note: as workaround, to solve the problem, I need to recompile the VALID incriminated package...
    That means doing the work two times !!
    Thank you for your help...
    Regards
    Thierry

    Sorry, but it's not the same problem...
    It's not about ORA-04068 "existing state of packages has
    been discarded".
    I know that you just need to re-execute the package in this case.
    But here I have a ORA-06508:
    ORA-06508 PL/SQL: could not find program unit being called
    Cause: An attempt was made to call a stored program that could not be found. The program may have been dropped or incompatibly modified, or have compiled with errors.
    Action: Check that all referenced programs, including their package bodies, exist and are compatible.
    I repeat, all objects are valid.
    I can re-execute the application, that means the packages too, but the error remain ...
    The only way the solve that is to re-compile the VALID package !!!! and i don't like that...
    Regards
    Thierry

  • ORA-04063: package body "SYS.INITJVMAUX" has errors

    Hi,
    I am upgrading the database from 9.2.0.1 to 9.2.0.6 on microsoft windows xp version 2002
    Following the readme of the patch 3948480 Oracle9i Patch Set Notes Release 2 (9.2.0.6.0) Patch Set 5 for Windows (32-Bit)
    When doing the Postinstallation Tasks step 8.2.2 Upgrade the Database step 6 running the catpatch.sql script getting the following error in the log file
    =====================================================
    Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY INITJVMAUX:
    LINE/COL ERROR
    23/1 PL/SQL: Statement ignored
    23/19 PLS-00201: identifier 'DBMS_ASSERT.NOOP' must be declared
    84/4 PL/SQL: Statement ignored
    84/22 PLS-00201: identifier 'DBMS_ASSERT.NOOP' must be declared
    call initjvmaux.drp('drop table java$rmjvm$aux')
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04063: package body "SYS.INITJVMAUX" has errors
    ==========================================================
    Regards,

    Check out status of components from dba_registry. In case you are not using JVM in your database and only java component is invalid, then you can ignore the error. Else you will be required to load java manually. Check metalink for same,
    -Amit
    http://askoracledba.wordpress.com

  • 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.

  • Override standard ORA error

    Would anyone know if it is possible to override standard Oracle errors?
    For example: My customer is currently implementing a new ERP System, however due to a number of 'urgent' change requests, I am being asked to apply PL/SQL code changes to a production environment during the working day.
    The standard "ORA-04068: existing state of packages has been discarded" message will then appear on all client machines (as you'd expect!).
    Is it possible to override this message globally to say, for example:
    "ORA-04068: PL/SQL Changes made log off and on again to continue"
    Regards,
    David Massey.

    wait!
    there is a tool called lmsgen which can help you to create such message files :
    $ lmsgen
    NLS Binary Message File Generation Utility: Version 10.2.0.1.0 - Production
    Copyright (c) Oracle 1979, 2004.  All rights reserved.
    CORE    10.2.0.1.0      Production
    Incorrect number of arguments specified!
    Syntax:
    LMSGEN <text file> <product> <facility> [language] [-i indir] [-o outdir]
    Where <text file> is a message text file
          <product>   the name of the product
          <facility>  the name of the facility
          [language]  optional message language in
                      <language>_<territory>.<character set> format
                      This is required if message file is not tagged properly
                      with language
          [-i indir]  optional directory where to locate the text file
          [-o outdir] optional directory where to put the generated binary file.HTH
    Laurent

  • Trying to understand...

    ... about invalid packages and when they can still be used without error. Let me explain with an example....
    SQL> CREATE TABLE t (val NUMBER);
    Table created.
    SQL>
    SQL> INSERT INTO t SELECT ROWNUM FROM DUAL CONNECT BY ROWNUM <= 200;
    200 rows created.
    SQL> CREATE OR REPLACE PACKAGE test2 IS
      2    PROCEDURE do_test2;
      3  END test2;
      4  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY test2 IS
      2    PROCEDURE do_test2 IS
      3      CURSOR cur_test IS
      4        SELECT * FROM t;
      5
      6      tot NUMBER := 0;
      7    BEGIN
      8      FOR i IN cur_test
      9      LOOP
    10        tot := tot + i.val;
    11      END LOOP;
    12      DBMS_OUTPUT.PUT_LINE('Total: '||tot);
    13    END;
    14  END test2;
    15  /
    Package body created.
    SQL> set serveroutput on
    SQL> exec test2.do_test2;
    Total: 20100
    PL/SQL procedure successfully completed.
    -- rename the table used by the package to invalidate it.
    SQL> RENAME t TO t2;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    -- Rename the table back, the status is still invalid as the package hasn't been recompiled yet.
    SQL> RENAME t2 TO t;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    -- Execute the procedure in the package and it is executing ok...
    SQL> exec test2.do_test2;
    Total: 20100
    PL/SQL procedure successfully completed.
    -- And upon checking the status of the package after it has automatically been compiled.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        VALID
    SQL>But with my real package and code....
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'PKG_MAPPING';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        VALID
    -- Execute the first step of the process in my package which drops and recreates a large materialized view and refreshes a smaller one using the DBMS_MVIEW package
    SQL> exec pkg_mapping.pre_mapping(1);
    PL/SQL procedure successfully completed.
    -- The status of the package has now been invalidated by that processing as expected...
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'PKG_MAPPING';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    -- If it try to run the second stage of the process I get the following error...
    SQL> exec pkg_mapping.pre_mapping(2);
    BEGIN pkg_mapping.pre_mapping(2); END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "CRISP_INTELL.PKG_MAPPING" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "CRISP_INTELL.PKG_MAPPING"
    ORA-06512: at line 1
    -- After this error, the state of the package is still invalid...
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'PKG_MAPPING';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    -- ... but running it a second time, it executes correctly and the package becomes valid in the process...
    SQL> exec pkg_mapping.pre_mapping(2);
    PL/SQL procedure successfully completed.
    SQL>So I know I must be missing something here. What is it that determines that you get the "ORA-04068: existing state of packages has been discarded" error rather than it just attempting to compile and run the procedure in the package, as happened in the test example?
    Anybody any ideas?

    I guess the only way to get around this is to take the package level variables out of the package and put those into a seperate packageif the global variables are not required across multiple client calls, you can avoid it like below:
    SQL> CREATE TABLE t (val NUMBER);
    Table created.
    SQL>
    SQL> INSERT INTO t SELECT ROWNUM FROM DUAL CONNECT BY ROWNUM <= 200;
    200 rows created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE test2 IS
      2    PROCEDURE do_test2;
      3  END test2;
      4  /
    Package created.
    SQL> show errors
    No errors.
    SQL> CREATE OR REPLACE PACKAGE BODY test2 IS
      2    x NUMBER ;
      3    PROCEDURE do_test2 IS
      4      CURSOR cur_test IS
      5        SELECT * FROM t;
      6
      7      tot NUMBER := 0;
      8    BEGIN
      9      FOR i IN cur_test
    10      LOOP
    11        tot := tot + i.val;
    12      END LOOP;
    13      DBMS_OUTPUT.PUT_LINE('Total: '||tot);
    14    END;
    15  END test2;
    16  /
    Package body created.
    SQL> show errors
    No errors.
    SQL>
    SQL> set serveroutput on
    SQL> exec test2.do_test2;
    Total: 20100
    PL/SQL procedure successfully completed.
    SQL> RENAME t TO t2;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    2 rows selected.
    SQL> RENAME t2 TO t;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    2 rows selected.
    SQL> exec test2.do_test2;
    BEGIN test2.do_test2; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "KKISHORE.TEST2" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "KKISHORE.TEST2"
    ORA-06512: at line 1
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    2 rows selected.
    SQL>
    SQL> DROP TABLE t ;
    Table dropped.
    SQL> CREATE TABLE t (val NUMBER);
    Table created.
    SQL>
    SQL> INSERT INTO t SELECT ROWNUM FROM DUAL CONNECT BY ROWNUM <= 200;
    200 rows created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE test2 IS
      2    PROCEDURE do_test2;
      3  END test2;
      4  /
    Package created.
    SQL> show errors
    No errors.
    SQL> CREATE OR REPLACE PACKAGE BODY test2 IS
      2    x NUMBER ;
      3    PROCEDURE do_test2 IS
      4      CURSOR cur_test IS
      5        SELECT * FROM t;
      6
      7      tot NUMBER := 0;
      8    BEGIN
      9      FOR i IN cur_test
    10      LOOP
    11        tot := tot + i.val;
    12      END LOOP;
    13      DBMS_OUTPUT.PUT_LINE('Total: '||tot);
    14    END;
    15  BEGIN
    16 dbms_session.reset_package ;
    17  END test2;
    18  /
    Package body created.
    SQL> show errors
    No errors.
    SQL>
    SQL> set serveroutput on
    SQL> exec test2.do_test2;
    PL/SQL procedure successfully completed.
    SQL> RENAME t TO t2;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    2 rows selected.
    SQL> RENAME t2 TO t;
    Table renamed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        INVALID
    2 rows selected.
    SQL> exec test2.do_test2;
    PL/SQL procedure successfully completed.
    SQL> SELECT object_type, status FROM USER_OBJECTS WHERE object_name = 'TEST2';
    OBJECT_TYPE         STATUS
    PACKAGE             VALID
    PACKAGE BODY        VALID
    2 rows selected.
    SQL>

  • Several errors after running catalog.sql

    I did a fresh installation of oracle apps EBS 11.5.10.2 on Linux OEL and was trying to do an import/export and it was not working as expected. So after i looked at Oracle's documentation it said catalog.sql has to be run before using the import/export. So i ran catalog.sql first but i did not run it with SYSDBA but ran it as SYSTEM and i saw several errors like access denied etcv. after i ran the catalog.sql i was not able to login via apps or any other user except SYSTEM and was giving me erros like ORA-04065:not executed,altered or dropped stored procedure "SYS.DBMS_SESSION"
    After this to fix the issue i ran @?/rdbms/admin/catpatch.sql and @?/rdbms/admin/utlrp as SYSDBA but both executed a lot of grants etc but are haging at some point and not finishing.
    The current state of the database is that im not able to login via any user except SYSTEM and i think i corrupted the db dictionary as everywhere i see they say running catalog.sql on an existing database is a bad idea. Can anyone help?

    Hi Dheeraj,
    My db version is 9.2.0.5.0 and OS is OEL 5.7.
    The doc where it was mentioned to run catalog.sql before using import/export is below:
    http://docs.oracle.com/cd/B10501_01/server.920/a96652/ch01.htm
    Please do not follow the steps in this link and instead follow the steps in (9i Export/Import Process for Oracle Applications Release 11i [ID 230627.1]).
    Currently when im trying to login using apps or any other user below are errors i get.
    ERROR:
    ORA-00604: error occurred at recursive SQL level1
    ORA-04068: existing state of packages has been discarded
    ORA-04065: not executed, altered or dropped stored procedure "SYS.DBMS_SESSION"
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512:at "SYS.OWA_VPD_CTX", line 5
    ORA-06512:at "SYS.PORTAL_LOGIN", line 3
    ORA-06512:at line 2
    Can you pls help me to fix this.The status of the package is invalid and you need to validate it. Connect as sysdba and issue:
    SQL> select owner, object_type, status
    from dba_objects
    where object_name = 'DBMS_SESSION';
    SQL> alter package DBMS_SESSION compile body;
    SQL> show error
    SQL> alter package DBMS_SESSION compile;
    SQL> show errorPlease also see:
    Data Dictionary Objects Invalid after Running catalog.sql, catproc.sql, utlrp.sql or catpatch.sql [ID 752783.1]
    Debug and Validate Invalid Objects [ID 300056.1]
    How to Diagnose Invalid or Missing Data Dictionary (SYS) Objects [ID 554520.1]
    Thanks,
    Hussein

  • Tricky : how to avoid this error transparent to users ?

    Hello, Oracle people !
    I probably have a very common problem / question ...
    We use third party application (called Kintana) that has some SQL queries referencing my custom Oracle views.
    Connection to Oracle via JDBC. Some of those views are also using packaged functions residing in one custom package. So when I need to change logic, I'm recompiling just PACKAGE BODY at off-hours time in production. But when next time user runs those queries via Kintana web interface they get an error :
    -- The following error is thrown by the Database:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "KNTA.OM_MISC_LIBRARY_PKG" has been invalidated
    ORA-04065: not executed, altered or dropped package body "KNTA.OM_MISC_LIBRARY_PKG"
    But when users refresh their screen on IE browser,
    error goes away. (probably Oracle calls it again and recompiles object restoring its valid state)
    I understand that how Oracle works,
    but I was given a task by Manager :
    "Make sure that users don't see this error !"
    (some of users are VIP, CIO, VPs and other "highly important" executives)
    So I tried to avoid this error but can't ...
    I don't know how to restore valid state of recompile package to existing user sessions without this error being seen ...
    Please HELP !!!
    thanx,
    Steve.

    I've been reluctant to tell you this since it could have some serious side effects and performance issues but you could reset the entire session package state by calling DBMS_SESSION.RESET_PACKAGE BEFORE you attempt the calls. The problem is that it resets ALL package's state information and I'm not aware of a way to do it for a single package. Unfortunately, it doesn't appear that you can call this routine after the exception occurs. For some reason, the exception seems to have to make it all the way back to the client before Oracle will acknowledge the reset.

Maybe you are looking for

  • BT Infinity - 3 orders, 10 wks, 30+ assistants an...

    First off, this is going to be a long post, but I have snapped and have lost the will to carry on now.  It is almost comical now and I'm intrigued in how much worse this can get. I also have to caveat I work in IT service and support for a large mult

  • Best Practices for AD and Windows Environment

    Hello Everyone, I need to create a document having the best practices for AD containing best practices for DNS, DHCP, AD Structure, Group Policy, Trust Etc. I just need the best practices irrespective of what is implemented in our company. I just nee

  • Importing from a scanner question.

    Hopefully this is a easy, but I can not file the answer to this. Is their a way to change the default file format when scanning to Photoshop CS5. It defaults to a BMP file I want it to a Jpeg file format? Thanks for the help.

  • Support for 6130

    I am in the process of renewing Oracle "Support for Systems". I have three items that according to: Oracle Lifetime Support Policy: Oracle Hardware and Operating Systems (February, 2012) [http://www.oracle.com/us/support/library/lifetime-support-hard

  • Opening tiff image file and finding pixel values at each point

    I want to open a tiff image file using java.Than i want to find out the pixel values at each point.Also if possible red,green and blue values. please mail me answer or code if possible on mail id: [email protected]