PRAGMA AOTONOMUS TRANSACATION

Y at - it a lead performance in the use of PRAGMA AOTONOMUS TRANSACATION?

Thank you

REDA

No,
An autonomous Transaction is "independent validation" with parent.

Example of
Autonomous transaction of procedure procedure
Start
Uptate has...
commit;
End;

TRIAL procedure
Start
Update B...
PROCEDURES;
Rollback;
End;

Update has commit, update in B is rollback.

Tags: Database

Similar Questions

  • feature request: support for #pragma how (lib, "... ") in CVI

    This pragma tell the compiler to link the library specified with the project. This construction is very useful for the distribution of libraries or source code: Add this to your head, and your library user does not have to include the .lib file in the project. It also avoids demolish the project file with all external libraries, which are usually only needed by one or 2 source files. This will also add a portability.

    Currently, CVI 8.5 seems to ignore the pragma: it does not generate a warning or an error, but the sopecified library is not linked with the project.

    Hello

    Please post product advice through our product suggestion Center:

    http://digital.NI.com/applications/PSC.nsf/default?OpenForm&Temp1=&node=

    This will ensure that your request goes to the right people ;-)

  • How to use Pragma instructions in BlackBerry 5.0

    Hi all

    How can we use SQLite Pragma in BlackBerry? Please help me with an example. When we run this pragma instructions? When creating the db or db opening?.

    Thank you

    Abees

    SQLite pragma statements are not supported on BlackBerry Smartphones.

  • Version of the schema via SQLite PRAGMA user_version

    I read some post on peacekeeping the schema via the PRAGMA version... From what I read, this method seems to be the right approach to implement. But in the last few days I've been running a few problems with my implementation... So, I have 2 questions...

    1. When I update the user_version PRAGMA, the value is never stored after each new load application...

      1st round (Application does not close on the device):

      Initial version of DB 0
      Version of DB 0
      DB Version 1
      DB Version 2
      DB Version 3

      2nd round

      Initial version of DB 1
      Version of DB 0
      DB Version 1
      DB Version 2
      DB Version 3

      To my knowledge, on the 2nd run the PRAGMA user_value must contain the value of 3... But it always starts at 1.

      This is the sequential code used to get and update the PRAGMA...

        // Retreive the DB schema version #
        QSqlQuery sqlQuery(sqlda->connection());
        sqlQuery.setForwardOnly(true);
        sqlQuery.exec("PRAGMA user_version");
      
        if (!sqlQuery.isActive())
        {
          // error
          qDebug() << "Error fetching DB Version.";
        }
      
        if (sqlQuery.next())
        {
          version = sqlQuery.value(0).toInt();
          qDebug() << "Initial DB Version " << version;
        }
      
        QSqlQuery sqlUpdateQuery(sqlda->connection());
        sqlQuery.setForwardOnly(true);
        sqlUpdateQuery.exec("PRAGMA user_version=0");
      
        ...
      
        sqlUpdateQuery.exec("PRAGMA user_version=3");
      
    2. In my class, I've decoupled the functions of the two as separate C++ function below version...
      int ApplicationUI::getDatabaseVersion()
      {
        // DB Version initialization
        int version = 0;
      
        // Create SQL Data Access object binding to the DB file...
        SqlDataAccess *sqlda = new SqlDataAccess(DB_PATH);
      
        // Retreive the DB schema version #
        QSqlQuery sqlQuery(sqlda->connection());
        sqlQuery.setForwardOnly(true);
        sqlQuery.exec("PRAGMA user_version");
      
        if (!sqlQuery.isActive())
        {
          // error
          qDebug() << "Error fetching DB Version.";
        }
      
        if (sqlQuery.next())
        {
          version = sqlQuery.value(0).toInt();
        }
      
        return version;
      }
      
      void ApplicationUI::updateDatabaseSchemaVersion(int version)
      {
        // Create SQL Data Access object binding to the DB file...
        SqlDataAccess *sqlda = new SqlDataAccess(DB_PATH);
      
        // Prepare the update statement
        QString sqlPragma = "PRAGMA user_version=" + QString::number(DB_VERSION);
        QSqlQuery sqlUpdateQuery(sqlda->connection());
        sqlUpdateQuery.setForwardOnly(true);
        sqlUpdateQuery.exec(sqlPragma);
        sqlda->connection().commit();
        qDebug() << "Updated PRAGMA to Version " << version;
      }
      
      void ApplicationUI::updateDatabaseSchema()
      {
        // Create SQL Data Access object binding to the DB file...
        SqlDataAccess *sqlda = new SqlDataAccess(DB_PATH);
      
        int version = 0;
      
        version = getDatabaseVersion();
        qDebug() << "Initial DB Version " << version;
        updateDatabaseSchemaVersion(2);
        version = getDatabaseVersion();
        qDebug() << "DB Version " << version;
        updateDatabaseSchemaVersion(4);
        version = getDatabaseVersion();
        qDebug() << "DB Version " << version;
        updateDatabaseSchemaVersion(6);
        version = getDatabaseVersion();
        qDebug() << "DB Version " << version;
        updateDatabaseSchemaVersion(7);
        version = getDatabaseVersion();
        qDebug() << "DB Version " << version;
      }
      

      in my test case, I generate some sequential update but whenever the application is running, I get the following message from the console:

      QSqlDatabasePrivate::removeDatabase: connection '. / data / bookDatabase.db' is still in use, all queries will stop working.
      QSqlDatabasePrivate::addDatabase: duplicate connection name '. / data / bookDatabase.db' old deleted connection.

      I tried to add the following sqlda-> connection (m:System.NET.Sockets.Socket.close ()); After calling SQL but the same message appears.

      You forgot something in my code... in c#, I usually wrap my SQL operations with a try catch/finally block. In the finally block, I close and have waiting them for connections...

    Thanks... dropped the PRAGMA and routed to a table of metadata according to the guidelines mentioned by perter9477 in the following thread...

    http://supportforums.BlackBerry.com/T5/native-development/best-approach-for-SQL-schema-version-upgra...

  • PRAGMA EXCEPTION_INIT works not as you wish

    Hi all

    I created a procedure where in I am trying to generate an error message saying "Table is missing from the database" when an id (2617804) is passed. To ensure that there is no such thing as the name of the table, then instead of the error is handled by OTHERS WHEN I want to be manipulated by my own error message and however which is a failure as well as control passes to 'OTHERS'.

    Can someone help me?

    Here is the code:

    Package:

    CREATE OR REPLACE PACKAGE CTNAPP.SANDEEP_XMLXTRACT IS
    
      /*****************************************************************************
      * Global Public Variables for error handling
      *****************************************************************************/
      g_vProgramName VARCHAR2(30):= 'CNZ017';
      g_vPackageName VARCHAR2(30):= 'CTN_PUB_CNTL_EXTRACT_PUBLISH';
      g_vProcedureName VARCHAR2(30);
      g_vTableName VARCHAR2(30);
      g_nSqlCd NUMBER;
      g_vErrorMessage VARCHAR2(2000); 
       
      /*****************************************************************************
      * Global Public Variables
      *****************************************************************************/  
      --Type declarations for GetCtnData procedure
      TYPE g_tVCArrayTyp IS 
      TABLE OF VARCHAR2(32767)
      INDEX BY BINARY_INTEGER;
      g_tVarcharArray g_tVCArrayTyp;
    
      TYPE g_tTblIDsTyp IS 
      TABLE OF NUMBER
      INDEX BY BINARY_INTEGER;
    
      PROCEDURE GetCtnData(p_nInCtnPubCntlID IN ctn_pub_cntl.ctn_pub_cntl_id%TYPE
      , p_tOutVarCharArray OUT g_tVCArrayTyp
      , pCount OUT NUMBER);
    
    
    
    
    
    
    

    Package body:

    CREATE OR REPLACE PACKAGE BODY CTNAPP.SANDEEP_XMLXTRACT IS
    
      -- Local Variables
      XMLctx DBMS_XMLGEN.CTXHANDLE;
      XMLdoc xmldom.DOMDocument;
      root_node xmldom.DOMNode;
      child_node xmldom.DOMNode;
      child_elmt xmldom.DOMElement;
      leaf_node xmldom.DOMNode;
      elmt_value xmldom.DOMText;
    
      vStrSqlQuery VARCHAR2(32767);
      nKiloByteLimit NUMBER(6) := 30000;
      dCurrentDate TIMESTAMP := SYSTIMESTAMP;
    
    -- Private Procedures 
      /************************************************************************
      *NAME : BuildCPRHeader
      *TYPE : FUNCTION
      *INPUT : 
      *OUTPUT : 
      *DESCRIPTION :  
      *  
      *************************************************************************/
      FUNCTION BuildCPRHeader RETURN VARCHAR2 IS
      vpublishHdr VARCHAR2(2000) := NULL;
      BEGIN
    
      XMLdoc := xmldom.newdomdocument;
      root_node := xmldom.makeNode(XMLdoc);
    
      child_elmt := xmldom.createElement(XMLdoc, 'PUBLISH_HEADER');
      child_node := xmldom.appendChild (root_node, xmldom.makeNode (child_elmt));
       
      child_elmt := xmldom.createElement (XMLdoc, 'SOURCE_APLCTN_ID');
      elmt_value := xmldom.createTextNode (XMLdoc, 'CTN');
      leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
      leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
      child_elmt := xmldom.createElement (XMLdoc, 'SOURCE_PRGRM_ID');
      elmt_value := xmldom.createTextNode (XMLdoc, g_vProgramName);
      leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
      leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
      child_elmt := xmldom.createElement (XMLdoc, 'SOURCE_CMPNT_ID');
      elmt_value := xmldom.createTextNode (XMLdoc, g_vPackageName);
      leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
      leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
      child_elmt := xmldom.createElement (XMLdoc, 'PUBLISH_TMS');
      elmt_value := xmldom.createTextNode (XMLdoc, TO_CHAR(dCurrentDate, 'YYYY-MM-DD HH24:MI:SS'));
      leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
      leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
      xmldom.writetobuffer(XMLdoc, vPublishHdr);
    
      RETURN vPublishHdr;
       
      END BuildCPRHeader;
    
    
    PROCEDURE GetCtnData(p_nInCtnPubCntlID IN ctn_pub_cntl.ctn_pub_cntl_id%TYPE, 
      p_tOutVarCharArray OUT g_tVCArrayTyp, 
      pCount OUT NUMBER)
      IS
      vTblName ctn_pub_cntl.table_name%TYPE;
      vLastPubTms ctn_pub_cntl.last_pub_tms%TYPE;
      l_clob CLOB;
      nCount PLS_INTEGER;
      nLength PLS_INTEGER;
      noffset PLS_INTEGER;
       
      table_not_found EXCEPTION;
      PRAGMA EXCEPTION_INIT(table_not_found, -00942);
       
      BEGIN
       
      g_vProcedureName:='GetCtnData';
       
      SELECT table_name, last_pub_tms
      INTO vTblName, vLastPubTms
      FROM CTN_PUB_CNTL
      WHERE ctn_pub_cntl_id = p_nInCtnPubCntlID;
       
      IF sql%ROWCOUNT = 0 THEN
      RAISE no_data_found;
      END IF;
    
      DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT','''YYYY:MM:DD HH24:MI:SS''');
      vStrSqlQuery := 'SELECT * FROM ' || vTblName
      || ' WHERE record_update_tms <= TO_DATE(''' || TO_CHAR(vLastPubTms, 'MM/DD/YYYY HH24:MI:SS') || ''', ''MM/DD/YYYY HH24:MI:SS'')'
      || ' AND rownum < 2'
      || ' ORDER BY record_update_tms'
      ;
    
      XMLctx := DBMS_XMLGEN.NEWCONTEXT(vStrSqlQuery);
      DBMS_XMLGEN.SETNULLHANDLING(XMLctx, 2);
      DBMS_XMLGEN.SETROWSETTAG(XMLctx, vTblName);
      l_clob := DBMS_XMLGEN.GETXML(XMLctx);
      l_clob := REPLACE(l_clob, '<?xml version="1.0"?>', '');
    
      l_clob := '<?xml version="1.0"?>' || CHR(13) || CHR(10)
      || '<PUBLISH> ' || CHR(13) || CHR(10)
      || BuildCPRHeader
      || '<PUBLISH_BODY> '
      || l_clob
      || '</PUBLISH_BODY> ' || CHR(13) || CHR(10)
      || '</PUBLISH>';
    
    -- l_clob := '<' || vTblName || '/>';
    
      nLength := DBMS_LOB.getlength(l_clob);
      nCount := CEIL(nLength / nKiloByteLimit);
    
      noffset := 1;
      IF (nCount > 0) THEN
      FOR i in 1 .. nCount LOOP
      p_tOutVarCharArray(i) := DBMS_LOB.SUBSTR(l_clob, nKiloByteLimit, noffset);
      noffset := noffset + nKiloByteLimit;
      dbms_output.put_line(p_tOutVarCharArray(i));
      END LOOP;
      END IF;
    
      pCount := nCount;
       
      EXCEPTION 
      WHEN table_not_found THEN
      RAISE_APPLICATION_ERROR(-20001,'Table is missing from the database');  
       
      WHEN no_data_found THEN
      CTNAPP_COMMON.write_log(g_vPackageName, g_vProcedureName, NULL,'INFORMATIONAL','XMLTOSAP');
       
      --WHEN too_many_rows THEN
      -- CTNAPP_COMMON.write_log(g_vPackageName, g_vProcedureName, NULL,'FATAL','XMLTOSAP');
       
      WHEN others THEN
      CTNAPP_COMMON.write_log(g_vPackageName, g_vProcedureName,NULL, 'ERROR','XMLTOSAP');
       
      END GetCtnData;
    

    and now, to call my own procedure:


    CREATE OR REPLACE PROCEDURE CTNAPP.SANDEEP_TEST_LAMXML
    IS
    
    l_tOutVarCharArray SANDEEP_XMLXTRACT.g_tVCArrayTyp;
    
    nCount NUMBER(5);
    
    BEGIN  
    END;
    /
    
    
    
     SANDEEP_XMLXTRACT.GetCtnData(2617804, l_tOutVarCharArray,nCount);
    
    
    
    


    When in 2617804 is an id that has a table name called 'sandeep' and this 'sandeep' is passed dynamically (such as there might be a table of someother name in the future) in the variable vStrSqlQuery.

    Can anyone let me know where I am going wrong. I tried a small prototype with PRAGMA EXCEPTION_INIT (which worked successfully) before generating the error for the production program manager.

    @Solomon and Jarkko: thanks for explaining things in detail and why this code is redundant. I'll remove it. As for the original question, it is now fixed. I spent just "EXECUTE IMMEDIATE vStrSqlQuery;" after "vStrSqlQuery" and that fixed the issue. He went immediately to the error handler I wanted him (WHEN table_not_found THEN) as opposed to "When OTHERS" Finally the issue is fixed. Thanks a lot for everyone taking the time. Very much appreciated.

  • Pragma EXCEPTION_INIT or RAISE_APPLICATION_ERROR - that is good practice

    Hello

    I have came across a point where I need suggestion and views on error handling. However I use above all error handler.
    But in case the base unit (inside) / program that calls that one would be preferable to use the PRAGMA EXCEPTION_INIT or directly use RAISE_APPLICATION_ERROR.

    Here's the example I've tried

    SQL> DECLARE
      2  L_CNT NUMBER;
      3  NO_DATA_FND EXCEPTION;
      4  PRAGMA EXCEPTION_INIT(NO_DATA_FND,100);
      5  BEGIN
      6   SELECT 1 INTO  L_CNT
      7       FROM DUAL WHERE 1=2;
      8  EXCEPTION
      9      WHEN NO_DATA_FND  THEN
     10      raise NO_DATA_FND  ;
     11  End;
     12  /
    DECLARE
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 10
    ORA-01403: no data found
    

    Or is better

    SQL> DECLARE
      2  L_CNT NUMBER;
      3  BEGIN
      4   SELECT 1 INTO  L_CNT
      5       FROM DUAL WHERE 1=2;
      6  EXCEPTION
      7      WHEN NO_DATA_FOUND THEN
      8      RAISE_APPLICATION_ERROR(-20001,'OR is this good way of handling');
      9  End;
     10  /
    DECLARE
    *
    ERROR at line 1:
    ORA-20001: OR is this good way of handling
    ORA-06512: at line 8
    

    No, it's not the same.

    Let's say you had a PL/SQL code you want to process the cases where you get an error ORA-01234 (for example), and you want to write an exception handler for it. You could use exception_init for card ORA-01234 an exception called MY_EXCEPTION and then use "when MY_EXCEPTION" in your exception handler. It has NOTHING to do with the throwing of an exception. You can also use this name to throw the exception directly

    raise_application_error throws an exception with a specific number and text associated with it. The error number must be within a specified range (-20000 29999 if memory serves).

  • pragma exception_init, initialize several exceptions

    Hi all

    Is it possible to initialize in the pragma even more then on exception?

    example:

    declare

    e_table_not_exists exception;

    exception of _divide_in_zero e;

    pragma

    exception_init (e_table_not_exists,-942), (e_divide_in_zero,-1476);

    .

    .

    Thanks in advance
    Naama

    No.; You must declare every exception_init in its own pragma.

    ex.:

    pragma exception_init (e_table_not_exists,-942);

    pragma exception_init (e_divide_in_zero,-1476);

  • Understanding Pragma Init Exception and others then exception...

    Hi gurus,

    I understand that using the pragma init exception, allows you to associate the user with valid error plsql code defined error message.

    But can not be managed using so that other then an exception? Using sqlerrm and sqlerrcode, we can display error messages and log them.

    Could you please help me understand this?

    Thank you

    I understand that using the pragma init exception, allows you to associate the user with valid error plsql code defined error message.

    Correct - the doc of the PL/SQL language

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/exceptioninit_pragma.htm

    The EXCEPTION_INIT pragma associates a name of the exception defined by the user with an error code.

    . . .

    Error_code

    Error code for being associated to exception . error_code may be 100 (digital code for "no data found" this 'function SQLCODE' return) or any negative integer greater than-10000000 except-1403 (another digital code for "no data found").

    This doc link also has examples of using the pragma

    But can not be managed using so that other then an exception? Using sqlerrm and sqlerrcode, we can display error messages and log them.

    Could you please help me understand this?

    First – understand this: If you do not go to 'manage' exception you shouldn't use an exception handler initially. Let the exception propagate up to the appellant.

    Second - you should NOT use THEN than OTHERS as a replacement for an appropriate exception handler.

    Which of them do you find easier to read, understand and maintain?

    1-60

    2 DEADLOCK_DETECTED

    Don't you think that ANYONE, no matter how expert, recalled all of the Oracle error codes? The names are much easier to understand than a number.

    The pragma is used so that you can explicitly declare an exception handler for one of the unnamed Oracle error codes.

    New - see the documentation

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/errors.htm#BABGIIBI

    To handle error conditions (generally ORA- messages) who do not have predefined name, you must use the OTHERS Manager or the pragma EXCEPTION_INIT .

    A pragma is a compiler directive which is processed at the time of compilation, not running.

    In PL/SQL, the pragma EXCEPTION_INIT tells the compiler to associate a name of the exception to an Oracle error number. Allows you to make reference to any inner exception by name, write a specific handler for it. When you see an error in the cell, or sequence of error messages, one on top is that you can intercept and manage.

    The pragma is used to catch an exception that "should" occur in the execution. Then, this exception can be handled. If it is NOT handled (for example if you just connect it) the exception handler should re - raise the exception rather than just swallowing it.

  • Pragma restrict_references problem

    PLS-00452: subprogramme violates its partner pragma

    I get this error when compiling a package. In fact, the problem is the following: I have a function that was written with variables of type 'DATE '. I migrated this function by everywhere replacing the types 'DATE' types "TIMESTAMP WITH time ZONE SCHEDULE", which is the only difference between the original function and modified. The initial function works, but the migration given the specified above failure. There is no interaction of data in a function, with the exception of a select, which is not affected by the change. Someone knows why this happens? Any help is greatly appreciated

    I solved the problem. I use some special functions for adding timestamp with timezone variables and the pragma should be added to them as well. Now it works

  • MO_GLOBAL. SET_ORG_ACCESS be pragma autonomous trxn

    Hello
    I was going through the body of MO_GLOBAL package. I could understand how SET_POLICY_CONTEXT, INIT, works etc and how they put the g_access_mode, g_current_org_id etc. But my question is on MO_GLOBAL. SET_ORG_ACCESS which is used to set the access mode to M.

    Seems MO_GLOBAL. SET_ORG_ACCESS is pragma autonomous Transaction. So how is he submissive for MO_GLOBAL. SET_ORG_ACCESS to set the access mode etc. of the session it is called from? However other procedures of the viz SET_POLICY_CONTEXT, INIT etc package are not Pragma autonomous Trxn.

    My question is... Suppose that I am connected to an Oracle session and from there I run MO_GLOBAL. SET_ORG_ACCESS (null, 2062, 'AR'). MO_GLOBAL. SET_ORG_ACCESS transaction autonomous pragma how it can set session variables for the session where I am connected?

    Please through little light to make my best understand.

    SB:-when a call of function/procedure/session a procedure autonomous trxn, will be two calls and called sharing the same session blocks? I thought that they both have different sessions.

    Thank you

    Clause autonomous transaction will launch an independent transaction, no new session as a test case below.

    DECLARE
    PROCEDURE A.
    AS
    pragma autonomous_transaction;
    BEGIN
    dbms_output.put_line (' autonomous transaction within my session id ' | sys_context ('USERENV', 'SID'));
    ROLLBACK;
    END;
    BEGIN
    dbms_output.put_line ('My session id' | sys_context ('USERENV', 'SID'));
    one;
    dbms_output.put_line (' autonomous external transaction my session id ' | sys_context ('USERENV', 'SID'));
    END;

    OUTPUT:

    My 531 session id
    Inside of an autonomous transaction my id of session 531
    Outside an autonomous transaction my id of session 531

  • Can we use RESTRICT_REFERENCES PRAGMA in procedure or function.

    Hello

    Can we use RESTRICT_REFERENCES PRAGMA procedure or function, instead of package.
    I know that in the package, we can use.

    My question is in individual procedure or function, we can use.

    Thank you and best regards,
    Sanjeev.

    The RESTRICTING REFERENCES pragma is discouraged. Why do you want to use?

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/restrictreferences_pragma.htm

    A RESTRICT_REFERENCES pragma can appear only in a package specification or object type specification. Typically, this pragma is specified for functions. If a function calls procedures, specify the pragma for those procedures also.
    
  • Set the error code for the exception qualified using the pragma exception_init

    Hello

    I did experiments on exception management in oracle plsql. In my experiments, I did the following anonymous plsql block.


    + < < outer_block > > +.
    declare
    + exceptions.    +
    Start
    + < < inner_block > > +.
    + State +.
    + exceptions.        +
    + start +.
    + recovery outer_block.exc +;
    + exception +.
    + What then outer_block.exc +.
    + dbms_output.put_line ("' outdoor Exception caught"); +
    + What then inner_block.exc +.
    + dbms_output.put_line ("'Inner Exception caught"); +
    + end; +
    end;


    When I run the code, I got the output "external Exception caught".

    ------------------------------------------------- PLSQL Block 2 -------------------------------------------

    I changed the code a little differently by assigning exceptions error codes.

    + < < outer_block > > +.
    declare
    + exception exc; +
    + pragma exception_init (exc,-20001); +
    Start
    + < < inner_block > > +.
    + State +.
    + exception exc; +
    + pragma exception_init (exc,-20001); +
    + start +.
    + raise_application_error (-20001, "Error"); +
    + exception +.
    + What then outer_block.exc +.
    + dbms_output.put_line ("' outdoor Exception caught"); +
    + What then inner_block.exc +.
    + dbms_output.put_line ("'Inner Exception caught"); +
    + end; +
    end;

    When I run the above code, I got the following error.

    Error on line 1
    ORA-06550: line 15, column 9:
    PLS-00484: exceptions redundant "EXC" and "EXC" must appear in the same exception handler
    ORA-06550: line 5, column 1:
    PL/SQL: Statement ignored

    Script done on line 21.

    ------------------------------------------------- PLSQL Block 3 -------------------------------------------


    To avoid this error, I changed the code again by qualifying exceptions with their block names. This time, I got a different error.

    + < < outer_block > > +.
    declare
    + exception exc; +
    + pragma exception_init (outer_block.exc,-20001); +
    Start
    + < < inner_block > > +.
    + State +.
    + exception exc; +
    + pragma exception_init (inner_block.exc,-20001); +
    + start +.
    + raise_application_error (-20001, "Error"); +
    + exception +.
    + What then outer_block.exc +.
    + dbms_output.put_line ("' outdoor Exception caught"); +
    + What then inner_block.exc +.
    + dbms_output.put_line ("'Inner Exception caught"); +
    + end; +
    end;


    Error on line 1
    ORA-06550: line 4, column 38:
    PLS-00103: encountered the symbol ". «» When expecting one of the following values:

    ), = >
    The symbol"were replaced by". "to continue.
    ORA-06550: line 9, column 42:
    PLS-00103: encountered the symbol ". «» When expecting one of the following values:

    ), = >
    The symbol"were replaced by". "to continue.



    Question:
    Pourraient several exceptions with the same name of the exception defined in the set of nested blocks plsql assign error codes using the pragma EXCEPTION_INIT? If there are errors in the PLSQL 2 blocks and 3, please suggest.
    If the same thing could be accomplished by other methods, please explain.

    The problem in your code block 2 is that you have not only used the same name of the exception, but you have assigned them with the same exception code. If the code is different so it will work...

    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
    
      1  <>
      2  declare
      3      exc exception;
      4      pragma exception_init(exc,-20001);
      5  begin
      6      <>
      7      declare
      8          exc exception;
      9          pragma exception_init(exc,-20002);
     10      begin
     11          raise_application_error(-20002,'Error raised');
     12      exception
     13          when outer_block.exc then
     14              dbms_output.put_line('outer Exception caught ' );
     15          when inner_block.exc then
     16              dbms_output.put_line('Inner Exception caught ' );
     17      end;
     18* end;
    SQL> /
    Inner Exception caught
    
    PL/SQL procedure successfully completed.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  <>
      2  declare
      3      exc exception;
      4      pragma exception_init(exc,-20001);
      5  begin
      6      <>
      7      declare
      8          exc exception;
      9          pragma exception_init(exc,-20002);
     10      begin
     11          raise_application_error(-20001,'Error raised');
     12      exception
     13          when outer_block.exc then
     14              dbms_output.put_line('outer Exception caught ' );
     15          when inner_block.exc then
     16              dbms_output.put_line('Inner Exception caught ' );
     17      end;
     18* end;
    SQL> /
    outer Exception caught
    
    PL/SQL procedure successfully completed.
    
  • Pragma Exception_INIT-doubt

    Hi all

    Why we use Pragma Exception_INIT what is the purpose?
    Declare     
          e_MissingNull EXCEPTION;
         PRAGMA EXCEPTION_INIT(e_MissingNull, -1400);
    BEGIN
         INSERT INTO Employees (employee_id) VALUES (NULL);
    EXCEPTION
         WHEN e_MissingNull then
            DBMS_OUTPUT.put_line('ORA-1400 occurred');
    END;
    When I give the code above I
    PL/SQL procedure successfully completed. ORA-1400 has occurred

    The same code when I try to give the error message is ORA-1500 took place
    I get
    ORA-01400: cannot insert NULL into ("XXI". "'"' EMPLOYEES'."" EMPLOYEE_ID')
    ORA-06512: at line 6
    Why is it happening?

    And when I use to try to get the error messgae to display not valid instead of Zero_divide
    Declare    
           I Number; 
          e_sample EXCEPTION;
         PRAGMA EXCEPTION_INIT(e_sample, -5737);
    BEGIN
         select 1/0 Into I From Dual ; -- I know Zero_Divide Error i thought the changing this error in my style 
    EXCEPTION
         WHEN e_smple then
            DBMS_OUTPUT.put_line('ORA-5737 Not valid');
    END;
    But the result is
    ORA-01476: divisor is equal to zero

    Please let me know the purpose and the use of Pragma Exception_INIT

    I thank in advance
    Suresh

    Please take a read of {: identifier of the thread = 697262} for a better understanding of the management of exceptions.

    Looks like you are trying to do parts of more advanced pragma of handling exceptions before you even understand the basics.

  • Can ' transaction autonomous pragma ' called from exception block?

    CREATE OR REPLACE TRIGGER TRIG_EMP
    AFTER UPDATE
    ON EMP
    FOR EACH LINE

    DECLARE

    NUMBER OF THE CNT: = 0;

    BEGIN

    UPDATE EMP_bkp
    SET COMM = 999
    WHERE ENAME = 'SMITH ';.

    COMMIT; -It will generate the error that commit the cnt b use inside the trigger then wil code exception sommunications

    exception
    while others then
    declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    Start
    commit;
    end;
    END;


    Why code gives error? cant I put PRAGMA AUTONOMOUS_TRANSACTION block of exception, even if I have the rolls in declare... begin... end of block.
    Could be considered to bear, but I m in delema why we cnt pragma 'use', in the exception block when an error themselves in code.as can call any proc, func via exception block then why don't we call pragma?

    A pragma shall apply to a set routine:
    -The anonymous PL/SQL blocks higher level (not nested)
    -Local, autonomous and packaged functions and procedures
    -A SQL object type methods
    -Database triggers

    But, even if you set a pragma autonomous_transaction in the exceptions, these commit will not commit the changes maded in the body of the trigger (because the idea of a stand-alone transaction, is independent).

    Perhaps (I'm not sure) you can try to trick Oracle write a function that do the validation.

    In any case, what you trying to do? There may be another way to achieve your goals

    I hope this helps.

    Kind regards
    Alfonso Vicente
    http / / www.logos.com.uy/el_blog_de_alfonso

  • pragma serial_resuable problem

    create or replace package pkg_serial_reusable
    as
    pragma serially_reusable;
    sfn_serial_resuable function return number;
    end pkg_serial_reusable;


    create package body pkg_serial_reusable
    as
    pragma serially_reusable;
    function sfn_serial_resuable
    Return number
    as
    l_code tmp_employee.code%type;
    Start
    Select the code in l_code to tmp_employee where code = '90142555';
    Return l_code;
    end sfn_serial_resuable;
    end pkg_serial_reusable;


    the package body and specification created without any errors... but when I call this function through the SQL his returns an error... the error is


    ORA-06534: cannot access the package series reusable 'DOBBELAERE. PKG_SERIAL_REUSABLE ".

    Please help me

    Hello

    Googling the error, the description indicates very clearly the problem...

    ORA-06534: cannot access reusable packaging in series
    Cause: The program has attempted to access a package in reusable PL/SQL series called context SQL (trigger or otherwise). Such access is not currently supported.

    SQL> CREATE OR REPLACE PACKAGE pkg_serial_reusable
      2  AS
      3     PRAGMA SERIALLY_REUSABLE;
      4
      5     FUNCTION sfn_serial_resuable
      6        RETURN NUMBER;
      7  END pkg_serial_reusable;
      8  /
    
    Package created.
    
    Elapsed: 00:00:00.06
    SQL> CREATE PACKAGE BODY pkg_serial_reusable
      2  AS
      3     PRAGMA SERIALLY_REUSABLE;
      4
      5     FUNCTION sfn_serial_resuable
      6        RETURN NUMBER
      7     AS
      8        l_code   tmp_employee.code%TYPE;
      9     BEGIN
     10        SELECT code
     11          INTO l_code
     12          FROM tmp_employee
     13         WHERE code = '90142555';
     14
     15        RETURN l_code;
     16     END sfn_serial_resuable;
     17  END pkg_serial_reusable;
     18  /
    
    Package body created.
    
    SQL> insert into tmp_employee values('90142555');
    
    1 row created.
    
    Elapsed: 00:00:00.00
    SQL> commit;
    
    Commit complete.
    
    Elapsed: 00:00:00.01
    SQL> exec :c:=pkg_serial_reusable.sfn_serial_resuable();
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.01
    SQL> select pkg_serial_reusable.sfn_serial_resuable from dual;
    select pkg_serial_reusable.sfn_serial_resuable from dual
           *
    ERROR at line 1:
    ORA-06534: Cannot access Serially Reusable package
    "JJACOB_APP.PKG_SERIAL_REUSABLE"
    ORA-06512: at line 1
    

    If you cannot call a function reusable serialy leave a SQL statement, but you can however call from PL/SQL.

    HTH

    David

Maybe you are looking for

  • By default on the Space Designer plugin?

    And the reason why I don't see the default settings on the Space Designer plugin?  Where it would normally be on the top of the effects window, there is nothing.  I have the same plug-in use all the time in the logic, no problems... Are there default

  • It not install HP DV1000 Sound and video drivers

    I just had to reformat my DV1000 because of a corrupted Windows XP installation. I downloaded the drivers on the HP site but they won't install, it just says: FAILURE at the end of an attempt to install them. The p/n my laptop is ED338AV. Any help wo

  • spreadsheet for table

    Hello I'm reading from a worksheet. PressDir =-1, 1, -1, 1 How I would do this job? I think my conversion code is wrong. But I tried everything.

  • LVRT.dll error

    I'm using LabView RTE 8.2.0.4002 to run an LV application which was built in LV 8.2. My application crashes sporadically. The error says output error file is in TDUtility.cpp (1432) and sometimes (1041), Unexpected: 8, 4, tc: 48, 48. The events of PC

  • Latitude E5520 - finding Webcam drivers

    I'm looking for an app for my integrated webcam. My Latitude is installed with Win7 64 bit. After a while, I found the 'dell webcam manager' but the application doesn't say, State none found, please install compatible webcam driver. Now I'm looking f