Rollback on insert

Hi,
I have on a pege two forms based on diferent tables . The first is based on AutomaticFetch/AutomaticRowProcessing and the second is a tabular form wich has ApplyMRU process.
I have a button CREATE wich fires both processes (AutomaticRowProcessing and ApplyMRU) and makes and insert into those two tables.
The problem is : if the second insert (wich is based on ApplyMRU) fails for some reason , the first insert (based on AutomaticRowProcessing) remain performed , even in the debug there is a 'Performing rollbak ...' .
On update I dont have this problem , the rollback works.
Any idea ?

The problem seems to be generated from the fact that I put an item name into 'Return Key Into Item' from AutomaticRowProcessing.If I remove that all is ok and rollback is executed.
Since I need a value to be returned from AutomaticRowProcess (is a value of primary key from a triger) what options I have ?

Similar Messages

  • JUnit/DBUnit rollback inserts/updates made by method being tested

    When performing JUnit/DBUnit testing, when you setup your data by inserting/updating rows during initialization, those insertions and updates would be rolledback automatically during the TearDown step of the Unit Test, right?
    My question is that if the inserts and updates are done on the method being tested what are the steps to rollback those inserts and updates?
    Can it be done implicitly by JUnit/DbUnit? or do we have to do it manually?
    We have an ADF Application Module method that is being J/DB-Unit tested and it calls a stored procedure that does a lot of things to many tables on the database. So it would be nice if the rollback was implicit.

    Anton,
    That would be nice, wouldn't it.
    Unfortunately, that's not the way it works. You have to rollback/undo your changes explicitly. As you asked on another thread, flashback would be a nice way of doing it. If you have a suite of tests that runs, you can flash back the entire database at the end to put the DB back into a known state.
    John

  • How to do rollback in a database control in ajpd

    Hello,
    I created a database control which has 3 methods that calls 3 respective stored procedures that inserts/updates tables. I have a jpd which uses the database control and calls each of the 3 methods. When it fails on the 3rd method, it doesn't rollback the inserts/updates done by the 2 methods. I'm using BEA's XA driver for SQL Server. Im new in this thing so please any help will be greatly appreciated.
    Thanks.
    Florence

    Dear Dinsh,
    Here are some links that will help you:
    http://download-uk.oracle.com/docs/cd/A97630_01/server.920/a96540/statements_510a.htm#2062405
    http://download-uk.oracle.com/docs/cd/A97630_01/server.920/a96540/toc.htm
    http://www.oracle.com/technology/products/oracle9i/index.html
    Regards,
    Francisco Munoz Alvarez

  • Need help in INSERT Script

    Message was edited by:
    NNK

    Hi,
    Its working but 90 records are getting inserted. If i didnt use this column either in insert OR SELECT ( --SUM_AUT_UNITS_USED) i getting only 30 records inserted.
    That is correct. Because the (AUT_CTRL_NBR) <> 1) = 30.
    In order to check again i rollbacked and inserted as u said. the record count shows
    1st time: 60 records -- again i tried
    2nd time: 30 records -- this time showed correct.
    I coudnt understand what happening. Please advice.
    Thanks

  • Needed to ROLLBACK failed Transaction

    Hi Oracle Expertz,
    QRY will Look Like
    BEGIN
    INSERT into tab3 RETURNING INTO v_exer_num
    UPDATE tab1
    SET col1 = ''
    WHERE exer_num = v_exer_num
    UPDATE tab2
    SET col1 = ''
    WHERE exer_num = v_exer_num
    END ;
    Example :
    1st record:
    Participant A
    Exer 1 Success
    Exer 2 Success
    2nd record
    Participant B
    Exer 1 Failed due to dead lock or some other exception.
    3rd Record
    Participant C
    Exer 1 Success
    Now in this transaction, I need to only rollback for Participant B ( failed Record) . Participants A and C should have committed the transaction. Can any one suggest me on this?
    Possiblities Of Exception :
    successful of INSERT , UPDATE , UPDATE will be considered as a completed tranasaction.
    For a particular record ( exer_num) , If insertion is executed successfully ,and updates failed for the corresponding exernum , I need to rollback the inserted record .
    Regards,
    Maran
    Edited by: Maran on Aug 6, 2009 1:17 PM

    Hey Sven ,
    thanks for your response. No these three DML statements would be executed inside my procedure. We can not run it in different session. the reason is
    as i said, completion of these 3 DML statements , then only will conisdered as a successful transaction else i need to roll back .
    also this will be called in a Batch JOB. we have a commit for whole transaction.
    Lets these are all the possibilites :
    1) INSERT FAILED ( ROW 1 )
    2) INSERT SUCCESS (ROW 2 )
    1st UPDATE Failed
    3) INSERT SUCCESS ( ROW 3 )
    1st UPDATE SUCCESS
    2nd UPDATE D FAILED
    4) INSERT SUCCESS ( ROW 4)
    UPDATE SUCCESS
    UPDATE SUCCESS
    Now for these scenario none of three statements got executed successfully . So if it fail between any of the statements , I need to rollback that particular row.
    Hope you understand the problem well now.
    Now can anyone suggest me that How can i handle this exception and need to keep going my transaction even if it fails in between.
    Objective over this problem is :
    Need to rollback Failed rows.
    Need to keep continue the Program , need to commit successful rows.
    Regards,
    MARAN
    Edited by: Maran on Aug 10, 2009 6:19 PM

  • Use of Rollback

    Good morning.
    I need to know if sentences like "CREATE TABLE AS SELECT..." or "INSERT /*+APPEND*/ INTO..." use the rollback segment or not.
    I need to find any form to create and load tables without using the rollback segment.
    Coul you help me?
    Thank you very much for your help.

    Do you want to minimize Redo logging or Undo
    (rollback)?
    INSERT /*+ APPEND */ is a method to minimize
    redo logging. It uses undo like any other
    insert statement and can be rolled back.The above statement is "Not true!".
    APPEND means "use direct insert". This means UNDO will not be logged. This has no direct effect on redo. If the table you are inserting into has USER_TABLES.LOGGING='N', then in addition to undo not being logged, redo will also not be logged. Also, other operations can specify nologging on the command line, such as CTAS or index creates and rebuilds, but those operations, by their very nature, are direct path loads.
    Bottom line is this:
    If you're not doing direct path, nologging has no effect. The only place that nologging has any effect is direct path loads. Direct path loads, by definition, avoid writing undo.
    Further, in a noarchivelog mode database, direct path load implies nologging. On an archivelog mode database, if you want to avoid redo generation on a direct path load, you have to ask for it explicitly. But, undo is always avoided for direct path loads.
    Hope thats clear,
    -Mark

  • Perfroming RollBack() For DML's

    Hi
    I have a sessionBean with CMT. The following is the method with Required Attribute in Bean:
    method A()
    try
         //call proc & Create Table T1
         //call proc & Create Table T2
         //Perform Insert in Table T3
         //Perform Insert in Table T4 -- This throws some kind of Exception e.g. SQLException
    catch(ApplicationLevelException e)
         sessionContext.setRollbackOnly();// to rollBack the inserts
         //call proc for Dropping the Tables created above
         throw e;// to rollBack()
    catch(SQLException e)
         // call proc for Dropping the Tables created above
         throw new EJBException();// to rollBack()
    }// end method A()
    Whenever any DML Statement is executed, it will implicitly commit all the previous DML's, if any. e.g. Inserts
    Hence, the problem with above is that once you call procedure for dropping Tables (which is considered as a DML) , it will automatically commit the Insert in Table T3.
    Is there any way in which I can perform RollkBack() for Insert in T3 and also Drop the tables T1 and T2?
    Thanks.

    No.
    Thats what my Bean is suppose to do.
    Create required Tables and Perform Inserts.
    In our scenario, you can assume that it wont be a costly operation.
    Back to the RollBack() issue, one thing that comes to my mind is when i call the DropTbl() procedure, the first thing it shud do it is : rollBack(). So, that it rolls back all the previous Inserts. And then it can go on Dropping created Tables.
    Is there any other way anyone suggest?

  • Can't catch the exception when transaction rollback ,BPEL/SOA 11G,updated!

    Hi Guys ,
    I have two insert/update invoke actions through dbadpter in my BPEL process .
    When I set the GetActiveUnitOfWork property of those two db adapters to true ,it successfully makes the global transaction work . any of them failed will cause the other rollback.
    But the CatchAll brunch can't catch the exception in that case,
    I can only see exception message from the system output :
    02/11/2009 11:36:46 AM oracle.toplink.transaction.AbstractSynchronizationListener beforeCompletion
    WARNING:
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.1.0) (Build 090527)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (Table1_PK) violated
    from BPEL console , you can't even see the error , the process finished with no exception.
    When I set GetActiveUnitOfWork to false, CatchAll brunch is able to catch the exception , but global rollback is not working .
    I try all the other method like set the transaction property of BPEL to required , using checkpoint() in java embedding . it looks like only way is set GetActiveUnitOfWork to true, but can't catch exception.
    Here are some updated:
    Here is my process
    Main Sequence
    Invoke (dbadapter update)
    Invoke (dbadapter insert)
    Global CatchAll
    Invoke(jmsAdapter sendjms)
    if I disable the CatchAll branch , when insert failed , the insert will rollback as well, even GetActiveUnitOfWork set to false.
    enable CatchAll branch , even doing nothing in this branch , the update won't rollback when insert failed. it looks like when catch the exception , bpel seems not rollback , I try to add throw rollback in catchall branch, no any effect.
    any clue ?
    Kevin
    Edited by: kyi on Nov 5, 2009 10:10 AM

    Hi All,
    We are also facing a similar kind of issue.
    We have a simple BPEL which will makes use of JAva embedding to call an end point to check its availibility.
    The Java code for cheking the enpoint connectivity is below
    try{      
    boolean endpointAvailable = false;
    long start = System.currentTimeMillis();
    int endpointTestURL_port = 8445 ;
    int endpointTestURL_timeout = 500;
    String endpointTestURL_queryString = "" ;
    String endpointTestURL_protocol = (String)getVariableData ("endpointProtocol");
    addAuditTrailEntry("endpointTestURL_protocol: " + endpointTestURL_protocol);
    String endpointTestURL_host = (String)getVariableData ("endpointHost");
    addAuditTrailEntry("endpointTestURL_hostl: " + endpointTestURL_host);
    URL endpoint = new URL(endpointTestURL_protocol, endpointTestURL_host, 8445, endpointTestURL_queryString);
    addAuditTrailEntry("endpoint object is created" );
    String endpointTestURL = endpoint.toExternalForm();
    addAuditTrailEntry("Checking availability of endpoint at URL: " + endpointTestURL);
    // Configure connection
    HttpURLConnection connection = (HttpURLConnection)endpoint.openConnection();
    connection.setRequestMethod("GET");
    addAuditTrailEntry("The Method is Get");
    connection.setConnectTimeout(5000);
    addAuditTrailEntry("Timeout is 500 ms");
    // Open connection
    connection.connect();
    addAuditTrailEntry("Open Connection");
    String responseMessage = connection.getResponseMessage();
    addAuditTrailEntry("Recieved availability response from endpoint as: " + responseMessage);
    // Close connection
    connection.disconnect();
    endpointAvailable = true;
    if (endpointAvailable)
    setVariableData("crmIsAvailable", "true");
    else
    setVariableData("crmIsAvailable", "false");
    catch(Exception e)
    System.out.println ("Error in checking endpoint availability " + e) ;
    addAuditTrailEntry("error message is : " +e);         
    When we run the above as a seperate java program it runs fine i.e goes to the catch block and catches the exception.
    But when we run it within the java embedding in BPEL(11G) it gives us the follwoing error.
    The reason was The execution of this instance "490001" for process "default/GMDSSalesLeadsBackMediationInterface!1.0*soa_e1a6362f-c148-417c-819c-9327017ebfa4" is supposed to be in an active jta transaction, the current transaction status is "ROLLEDBACK" .
    Consult the system administrator regarding this error.
         at com.oracle.bpel.client.util.TransactionUtils.throwExceptionIfTxnNotActive(TransactionUtils.java:119)
         at com.collaxa.cube.engine.CubeEngine.store(CubeEngine.java:4055)
         at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4372)
         at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4281)
         at com.collaxa.cube.engine.CubeEngine._createAndInvoke(CubeEngine.java:713)
         at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:545)
         at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:654)
         at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:355)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.jee.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:104)
         at oracle.security.jps.ee.ejb.JpsAbsInterceptor$1.run(JpsAbsInterceptor.java:88)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
         at oracle.security.jps.wls.JpsWeblogicEjbInterceptor.runJaasMode(JpsWeblogicEjbInterceptor.java:61)
         at oracle.security.jps.ee.ejb.JpsAbsInterceptor.intercept(JpsAbsInterceptor.java:106)
         at oracle.security.jps.ee.ejb.JpsInterceptor.intercept(JpsInterceptor.java:106)
         at sun.reflect.GeneratedMethodAccessor960.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.jee.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:69)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInte
    we also get
    BEA1-108EA2A88DAF381957FF
    weblogic.transaction.internal.TimedOutException: Transaction timed out after 301 seconds
    BEA1-108EA2A88DAF381957FF
         at weblogic.transaction.internal.ServerTransactionImpl.wakeUp(ServerTransactionImpl.java:1733)
         at weblogic.transaction.internal.ServerTransactionManagerImpl.processTimedOutTransactions(ServerTransactionManagerImpl.java:1578)
         at weblogic.transaction.internal.TransactionManagerImpl.wakeUp(TransactionManagerImpl.java:1900)
         at weblogic.transaction.internal.ServerTransactionManagerImpl.wakeUp(ServerTransactionManagerImpl.java:1488)
         at weblogic.transaction.internal.WLSTimer.timerExpired(WLSTimer.java:35)
         at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    javax.ejb.EJBException: Transaction Rolledback.: weblogic.transaction.internal.TimedOutException: Transaction timed out after 301 seconds
    BEA1-108EA2A88DAF381957FF
    We tried the following
    Increase the JTA timeout in the EM console to a larger value like 600 secs.
    The BPEL instance is not getting created.
    Any help would be appreciated
    Thanks
    Lalit

  • Rollback automatic if Document.Add fails ?

    Hi,
    please have a look to this code
    oCompany.startTransaction
    If (0 <> objInvoice.Add()) Then
    do you confirm that if Add or Update or other similar operations fails, the transaction automatically rollback without inserting this line of code?
    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
    I find this thing debugging my code.
    Has it always been so or only in last versions of SDK - DI ?
    Thank you
    Andy

    when working with a single object like the invoice object - SBO handles the transaction for you. thus when the add fails the system handles it for you - same thing if the add succeeds. you should only use transactions when you are doing adds/updates on multiple objects that rely on each other.
    thus:
    1. start transaction
    2.1 add/update object 1
    2.2 add/update object 2
    2.3 add/update object 1
    3. commit trnasaction
    or
    on exception or failure of 1 of the objects
    roll back
    NB : if you start a transaction, you HAVE to end it with a commit OR rollback

  • Rollbacking huge records

    Hi,
    we are getting a daily feed of 7 million records and need to be inserted to the oracle table.
    After loading we identified that there were some issues in the data loaded and want to load new 7 milllion records.
    a)first of all, database design should not allow incorrect data to be inserted.
    b)After inserting due to design flaw, how we can rollback and insert new 7 million records?
    Whats the best way to achieve that rather than going for a delete statement.
    The table is partitioned based on month.
    Thanks

    Pandeesh wrote:
    Hi,
    we are getting a daily feed of 7 million records and need to be inserted to the oracle table.
    After loading we identified that there were some issues in the data loaded and want to load new 7 milllion records.
    a)first of all, database design should not allow incorrect data to be inserted.What determines "correct"?
    >
    b)After inserting due to design flaw, how we can rollback and insert new 7 million records?You can not ROLLBACK any data that has been COMMITTED.
    >
    Whats the best way to achieve that rather than going for a delete statement.How do you unring the bell?
    >
    The table is partitioned based on month.SO?

  • Nested Try/Catch in a stored procedure going to outer

    I am using Service Broker to move data to a historical database and then delete it from the current table in a second stored procedure that gets the information passed to it; which I have working but what I am having trouble with is when there
    is an error in the second stored procedure rather than going to the catch in the second Stored procedure it goes back up to my first one.
    CREATE PROCEDURE [sp_PkgDelActivator_SB]
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
    DECLARE @RecvReqMsg XML;
    DECLARE @RecvReqMsgName sysname;
    BEGIN TRY
    WHILE (1=1)
    BEGIN
    BEGIN TRAN
    --Get the top item on the queue.
    WAITFOR
    ( RECEIVE TOP(1)
    @RecvReqDlgHandle = conversation_handle,
    @RecvReqMsg = message_body,
    @RecvReqMsgName = message_type_name
    FROM DeleteReceiveQueue
    ), TIMEOUT 5000;
    IF (@@ROWCOUNT = 0)
    BEGIN
    ROLLBACK TRANSACTION;
    BREAK;
    END
    ELSE
    COMMIT TRAN
    EXEC sp_PkgDeleteHeap_SB
    @RecvReqDlgHandle = @RecvReqDlgHandle,
    @RecvReqMsg = @RecvReqMsg
    END
    END TRY
    BEGIN CATCH
    DECLARE @ERR_NR INT = ERROR_NUMBER(),
    @ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
    @ERR_STT_NR TINYINT = ERROR_STATE(),
    @ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
    @ERR_LN_NR INT = ERROR_LINE(),
    @ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
    IF @@TRANCOUNT > 0
    ROLLBACK TRAN
    INSERT INTO DB_ERR_LOG(
    ERR_NR,
    ERR_SVR_NR,
    ERR_STT_NR,
    ERR_PRC_TE,
    ERR_LN_NR,
    ERR_MSG_TE,
    LOG_DT)
    SELECT
    @ERR_NR,
    @ERR_SVR_NR,
    @ERR_STT_NR,
    @ERR_PRC_TE,
    @ERR_LN_NR,
    @ERR_MSG_TE,
    GETDATE()
    END CATCH
    END
    CREATE PROCEDURE [sp_PkgDeleteHeap_SB]
    @RecvReqDlgHandle UNIQUEIDENTIFIER,
    @RecvReqMsg XML
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    BEGIN TRY
    BEGIN TRANSACTION
    DECLARE @dtArrival date = 'gotten from somewhere else'
    IF @dtArrival BETWEEN '2014-07-01' AND '2014-09-30'
    BEGIN
    'Code to move and delete rows from a table'
    END
    ELSE IF @dtArrival BETWEEN '2015-01-01' AND '2015-03-31'
    BEGIN
    'Code to move and delete rows from a table'
    END
    ELSE IF @dtArrival BETWEEN '2015-04-01' AND '2015-06-30'
    BEGIN
    'Code to move and delete rows from a table'
    END
    END CONVERSATION @RecvReqDlgHandle WITH CLEANUP;
    END
    COMMIT TRAN
    END TRY
    BEGIN CATCH
    ROLLBACK TRAN
    DECLARE @ERR_NR INT = ERROR_NUMBER(),
    @ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
    @ERR_STT_NR TINYINT = ERROR_STATE(),
    @ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
    @ERR_LN_NR INT = ERROR_LINE(),
    @ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
    'Code to send the message back into the queue'
    INSERT INTO DB_ERR_LOG(
    ERR_NR,
    ERR_SVR_NR,
    ERR_STT_NR,
    ERR_PRC_TE,
    ERR_LN_NR,
    ERR_MSG_TE,
    LOG_DT)
    SELECT
    @ERR_NR,
    @ERR_SVR_NR,
    @ERR_STT_NR,
    @ERR_PRC_TE,
    @ERR_LN_NR,
    @ERR_MSG_TE,
    @END_TS
    END CATCH
    END
    Thanks for any help.
    Also if this is not the right area for this question I am sorry please tell me and I will try moving it to the right area.

    >>Please guide me how to create Stored Procedure and how to load datas into Flatfile table and from Flatfile Table to Parent and Child Table.
    Can you try loading the data using SSIS package ? If that's not an option , you could try OPENROWSET
    --from the linkUSE AdventureWorks2012;
    GO
    CREATE TABLE myTable(FileName nvarchar(60),
    FileType nvarchar(60), Document varbinary(max));
    GO
    INSERT INTO myTable(FileName, FileType, Document)
    SELECT 'Text1.txt' AS FileName,
    '.txt' AS FileType,
    * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document;
    GO
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • (V9I) ORACLE 9I NEW FEATURE : RESUMABLE SPACE ALLOCATION

    제품 : ORACLE SERVER
    작성날짜 : 2002-11-01
    (V9I) ORACLE 9I New Feature : Resumable Space Allocation
    =====================================================
    PURPOSE
    Oracle9i New Feature 인 Resumable Space Allocation 에 대해
    알아보도록 한다.
    Explanation
    Resumable Space Allocation 은 다음과 같은 새로운 Space allocation
    이 발생되어야 할 시점에 에러를 바로 발생하지 않고 어느정도의 Time 을 준뒤
    Admin에게 이를 알림으로써 수행중인 Transaction rollback 되지 않고 계속적으로
    진행할 수 있도록 하는 기능이다.
    Query 수행시 다음과 같은 원인으로 에러가 발생하면서 query 수행이 중지된다.
    1) Out of space condition
    2) Maximum number of extents reached condision
    3) Space quota exceeded condition
    그러나 9I 에서 Resumable Space Allocation Operations을 설정하게 되면
    alertSID.ora file에 suspend 되는 메세지와 함께 설정한 timeout 까지 hang 상태가
    발생된다. 만약 timeout 초과시엔 에러가 발생하면서 transaction은 rollback 된다.
    alertSID.ora 메세지예)
    Wed Mar 14 11:14:17 2001
    statement in resumable session 'User SCOTT(54), Session 9, Instance 1' was
    suspended due to
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    Example
    다음은 Resumable Space Allocation Operations 을 설정하기 위해서는 RESUMABLE 을
    ENABLE 시키고 또는 DBMS_RESUMABLE package를 이용한다.
    1) RESUMABLE system privilege 부여
    SQL> connect system/manager
    Connected.
    SQL> grant resumable to scott;
    Grant succeeded.
    2) session level에서 RESUMABLE enable 시키기
    SQL> alter session enable resumable;
    Session altered.
    This can be set automatically through an AFTER LOGON trigger.
    SQL> create or replace trigger logon_set_resumable
    2 after logon
    3 on scott.schema
    4 begin
    5 execute immediate 'alter session enable resumable timeout 1200';
    6 end;
    7 /
    Trigger created.
    3) 생성한 TEST_RESUMABLE table 에 insert 작업
    -> insert 시에 hang 현상 발생(transaction rollback은 이루어지지 않는다.)
    -> alert.log에 suspend message 확인
    -> 만약 설정한 timeout 초과시 에러 발생되면서 transaction rollback
    a. Displaying the DBA_RESUMABLE view(DBA_RESUMABLE view에서 suspend 확인)
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, SUSPEND_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    USER_ID SESSION_ID STATUS START_TIME SUSPEND_TIME
    SQL_TEXT
    ERROR_NUMBER
    ERROR_MSG
    54 9 SUSPENDED 03/14/01 10:49:25 03/14/01 11:14:17
    insert into test_resumable select * from test_resumable
    1631
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    b. In alert.log file(alert.log에서 message 확인)
    Wed Mar 14 11:14:17 2001
    statement in resumable session 'User SCOTT(54), Session 9, Instance 1' was
    suspended due to
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    c. The statement may issue the following error when the timeout set for the
    session has expired(timeout 초과시 transaction rollback 되면서 에러 발생)
    SQL> insert into test_resumable values (1);
    insert into test_resumable values (1)
    ERROR at line 1:
    ORA-30032: the suspended (resumable) statement has timed out
    ORA-01536: space quota exceeded for tablespace 'EXAMPLE'
    4) The DBA now knows why the session hangs, and needs to find which action to
    take to alleviate the ora-1631 error(DBA는 timeout 이 발생하기 전에 에러 발생)
    SQL> connect system/manager
    Connected.
    SQL> alter table scott.test_resumable storage (maxextents 8);
    Table altered.
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, RESUME_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    USER_ID SESSION_ID STATUS START_TIME RESUME_TIME
    SQL_TEXT
    ERROR_NUMBER
    ERROR_MSG
    54 9 NORMAL 03/14/01 10:49:25 03/14/01 11:24:02
    insert into test_resumable select * from test_resumable
    0
    5) If the session does not need to be in resumable state, the session can
    disable the resumable state(더이상 resumable 기능 사용하지 않을 경우 disable 시키기)
    SQL> alter session disable resumable;
    Session altered.
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, RESUME_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    no rows selected
    Reference Document
    Note. 136941.1 Using RESUMABLE Session to Avoid Transaction Abort Due to Space Errors

    제품 : ORACLE SERVER
    작성날짜 : 2002-11-01
    (V9I) ORACLE 9I New Feature : Resumable Space Allocation
    =====================================================
    PURPOSE
    Oracle9i New Feature 인 Resumable Space Allocation 에 대해
    알아보도록 한다.
    Explanation
    Resumable Space Allocation 은 다음과 같은 새로운 Space allocation
    이 발생되어야 할 시점에 에러를 바로 발생하지 않고 어느정도의 Time 을 준뒤
    Admin에게 이를 알림으로써 수행중인 Transaction rollback 되지 않고 계속적으로
    진행할 수 있도록 하는 기능이다.
    Query 수행시 다음과 같은 원인으로 에러가 발생하면서 query 수행이 중지된다.
    1) Out of space condition
    2) Maximum number of extents reached condision
    3) Space quota exceeded condition
    그러나 9I 에서 Resumable Space Allocation Operations을 설정하게 되면
    alertSID.ora file에 suspend 되는 메세지와 함께 설정한 timeout 까지 hang 상태가
    발생된다. 만약 timeout 초과시엔 에러가 발생하면서 transaction은 rollback 된다.
    alertSID.ora 메세지예)
    Wed Mar 14 11:14:17 2001
    statement in resumable session 'User SCOTT(54), Session 9, Instance 1' was
    suspended due to
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    Example
    다음은 Resumable Space Allocation Operations 을 설정하기 위해서는 RESUMABLE 을
    ENABLE 시키고 또는 DBMS_RESUMABLE package를 이용한다.
    1) RESUMABLE system privilege 부여
    SQL> connect system/manager
    Connected.
    SQL> grant resumable to scott;
    Grant succeeded.
    2) session level에서 RESUMABLE enable 시키기
    SQL> alter session enable resumable;
    Session altered.
    This can be set automatically through an AFTER LOGON trigger.
    SQL> create or replace trigger logon_set_resumable
    2 after logon
    3 on scott.schema
    4 begin
    5 execute immediate 'alter session enable resumable timeout 1200';
    6 end;
    7 /
    Trigger created.
    3) 생성한 TEST_RESUMABLE table 에 insert 작업
    -> insert 시에 hang 현상 발생(transaction rollback은 이루어지지 않는다.)
    -> alert.log에 suspend message 확인
    -> 만약 설정한 timeout 초과시 에러 발생되면서 transaction rollback
    a. Displaying the DBA_RESUMABLE view(DBA_RESUMABLE view에서 suspend 확인)
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, SUSPEND_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    USER_ID SESSION_ID STATUS START_TIME SUSPEND_TIME
    SQL_TEXT
    ERROR_NUMBER
    ERROR_MSG
    54 9 SUSPENDED 03/14/01 10:49:25 03/14/01 11:14:17
    insert into test_resumable select * from test_resumable
    1631
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    b. In alert.log file(alert.log에서 message 확인)
    Wed Mar 14 11:14:17 2001
    statement in resumable session 'User SCOTT(54), Session 9, Instance 1' was
    suspended due to
    ORA-01631: max # extents (5) reached in table SCOTT.TEST_RESUMABLE
    c. The statement may issue the following error when the timeout set for the
    session has expired(timeout 초과시 transaction rollback 되면서 에러 발생)
    SQL> insert into test_resumable values (1);
    insert into test_resumable values (1)
    ERROR at line 1:
    ORA-30032: the suspended (resumable) statement has timed out
    ORA-01536: space quota exceeded for tablespace 'EXAMPLE'
    4) The DBA now knows why the session hangs, and needs to find which action to
    take to alleviate the ora-1631 error(DBA는 timeout 이 발생하기 전에 에러 발생)
    SQL> connect system/manager
    Connected.
    SQL> alter table scott.test_resumable storage (maxextents 8);
    Table altered.
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, RESUME_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    USER_ID SESSION_ID STATUS START_TIME RESUME_TIME
    SQL_TEXT
    ERROR_NUMBER
    ERROR_MSG
    54 9 NORMAL 03/14/01 10:49:25 03/14/01 11:24:02
    insert into test_resumable select * from test_resumable
    0
    5) If the session does not need to be in resumable state, the session can
    disable the resumable state(더이상 resumable 기능 사용하지 않을 경우 disable 시키기)
    SQL> alter session disable resumable;
    Session altered.
    SQL> select user_id,SESSION_ID, STATUS, START_TIME, RESUME_TIME,
    2 SQL_TEXT, ERROR_NUMBER, ERROR_MSG
    3 from dba_resumable;
    no rows selected
    Reference Document
    Note. 136941.1 Using RESUMABLE Session to Avoid Transaction Abort Due to Space Errors

  • Error handling in Oracle

    Hello,
    Could anyone help to convert the following T-SQL statement to PL-SQL? Thanks inadvance!
    BEGIN TRAN
    UPDATE Table1 SET .......
    SELECT @ReturnCode = @@error
    IF @ReturnCode <> 0
         BEGIN          
              SELECT @msg = 'Error - update date feed'
    GOTO Err_Handler
         END     
    COMMIT TRAN
    RETURN 0
    Err_Handler:          
              ROLLBACK TRAN
              INSERT INTO LogTable(ProcessName, ProcessStatus)
                   VALUES('Daily date feed', @msg)
              EXEC msdb.dbo.sp_send_dbmail      
                   @recipients = '[email protected]',
                   @Subject = 'Daily datafeed process failed',
                   @body = @msg          
              RETURN 1

    Sänjay wrote:
    Hi,
    Anonymous block example
    SQL> declare
    2   x number ;
    3  begin
    4    select count(*) into x from dual ;
    5    update emp set empno=empno ;
    6    dbms_output.put_line('Rows updated '|| sql%rowcount);
    7  exception -- Exception Or Error Handling
    8   when others then
    9    rollback ;
    10    dbms_output.put_line(SQLERRM);
    11  end ;
    12  /
    Rows updated 14
    PL/SQL procedure successfully completed.SSAwful example! I would fire programmers who would repeatetly produce such code. Rule #1: Avoid "when others expetions" wherever possible!
    I know you're capable of give much better examples.
    Btw: This code would produce the same result in sql*plus without any exception block:
    proof
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for HPUX: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL>
    SQL> drop table test;
    Table dropped.
    SQL> set serveroutput on
    SQL> create table test (col1 number);
    Table created.
    SQL>
    SQL> /* first without exception */
    SQL> declare
      2     x number ;
      3  begin
      4     insert into test values (1);
      5     select length(dummy) into x from dual where 1=1;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from test;
          COL1
             1
    SQL>
    SQL> /* now add some error */
    SQL>
    SQL> declare
      2     x number ;
      3  begin
      4     insert into test values  (2);
      5     select length(dummy) into x from dual where 1=2;
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 5
    SQL>
    SQL> select * from test;
          COL1
             1
    SQL>
    SQL> As you can see the second insert was rollbacked. But be careful, this works only for ANONYMOUS pl/sql blocks.
    Edited by: Sven W. on Jul 24, 2009 3:17 PM

  • Sending message to MQ is not particpating in existing Transaction

    We are using MessageDrivenBean and have following transaction properties,
    (a) transaction-type = "Container".
    (b) trans-timeout-seconds = "60"
    Note : We are using 2 PHASE Commit
    We have made sure that Oracle Driver is XA Enabled.
    And our MQ is also XA enabled (com.ibm.mq.jms.MQXAQueueConnectionFactory)
    We have following 3 activities in MDB
    1) Getting the message from MQ (OnMessage() is invoked)
    2) Calling Oracle Stored Procedure
    3) Sending XML message to another MQ Queue
    Sometimes, we have seen that the procedures takes around 93 seconds to respond.
    In that case, after getting back the control from procedure, ideally weblogic should issue a runtime exception,
    because we have specified transaction timeout to 60 seconds.
    Later, when container determines that transaction took more than 60 seconds, it issue a rollback.
    In that case, Step no. 1 & 2 is ROLLBACKED. Step-3 is NOT ROLLBACKED.
    Now, i have 2 questions,
    (a) Once we get control back from stored procedure after 93 seconds, why container doesn't throw
    runtime exception & issue transction rollback ?
    (b) Lets say, it doesn't, then how to enlist JMS Resource in existing weblogic transaction,
    so that, if the rollback happens, all 3 above steps should rollbacked.
    We are using SPRING Framework by looking up JmsTemplate102 object and calling "convertAndSend() method"
    <bean id="csmToIBus1" class="org.springframework.jms.core.JmsTemplate102">
         <property name="connectionFactory">
              <ref bean="jmsQueueConnectionFactory"/>
         </property>
         <property name="destinationResolver">
              <ref bean="jmsDestinationResolver"/>
         </property>
         <property name="pubSubDomain">
              <value>false</value>
         </property>
         <property name="defaultDestinationName">
              <value>QueueName1</value>
         </property>
    </bean>
    <bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory102">
         <property name="targetConnectionFactory">
              <ref bean="internalJmsConnectionFactory"/>
         </property>
         <property name="pubSubDomain">
              <value>false</value>
         </property>
    </bean>
    <!-- JMS Destination Resolver -->
    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
         <property name="jndiTemplate">
              <ref bean="jndiTemplate"/>
         </property>
         <property name="cache">
              <value>true</value>
         </property>
         <property name="fallbackToDynamicDestination">
              <value>true</value>
         </property>
    </bean>
    <!-- Spring JMS Queue Connection Factory -->
    <bean id="internalJmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
         <property name="jndiTemplate">
              <ref bean="jndiTemplate"/>
         </property>
         <property name="jndiName">
              <value>QCF1</value>
         </property>
    </bean>
    Any hints will be highly appreciated.
    Thanks,
    Shashi
    Email : [email protected]
    Edited by informshashi at 08/10/2007 12:35 PM
    Edited by informshashi at 08/10/2007 12:36 PM

    I'd first prove that these really aren't running in the same transaction. One easy way would be to have the EJB2 mark the transaction for rollback (EJBContext.setRollbackOnly). That should rollback the insert as well. Another option would be to print out the current transaction ID in both methods.
    If they are participating in the same transaction, I would look at the SQL log in the database (or from WLS). Can you show me the SQL that is being executed?
    -- Rob
    WLS Blog http://dev2dev.bea.com/blog/rwoollen/

  • Business rules to  implement - BEST way -  triggers and mutating table

    I have the following table where it has Foreign Key defined on itself(self reference for parent_id column which can be null or valid site_id)
    create table test_virtual_site
    site_id number CONSTRAINT site_id_pk primary key,
    parent_id number CONSTRAINT parent_site_id_unq UNIQUE ,
    closed_date date default NULL ,
    CONSTRAINT check_self_ref CHECK(parent_site_id <> site_id), --avoid self refernce
    CONSTRAINT check_valid_site foreign key(parent_site_id) references test_virtual_site(site_id)
    I have the following business rules to implement and my problem is related to their implementation
    1)     A check should be made that Site_id specified as parent_id should not be a child of any other store (parent should have its parent_id column as NULL)
    Site_id Parent_id
    1
    2 1
    3 2 =>NOT VALID 2 is a child of another store
    2)     Parent is not closed
    Site_id Parent_id Closed_date
    1 10-May-2005
    3     1 =>NOT VALID 1 is a closed
    3)
    when parent store is closed - updated so at closed_date is not null
    Want to set the parent_id as NULL for the child store.
    OR
    SET the closed_date for child store too same as the parent_store.
    Example
    Site_id Parent_id Closed_date
    1     
    1 2
    Update test_virtual_site
    SET closed_date = sysdate
    Where site_id = 1 ;
    Through Trigger
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1 2 22-Mar-06
    OR
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1
    When I am trying to do the above mentioned through constraints I am running into mutating trigger problem. Can you please guide me what is the best way to handle the above-mentioned scenarios.
    I am aware that I can avoid the 3rd problem using the following
    -- - Initialize an array in the before statement trigger.
    -- - Add the processed rowid to the array in the after row
    -- trigger.
    -- - In the after statement trigger: get each rowid from the
    -- array and process it. When all rowids are processed, clear
    -- the array.
    BUT for 1 and 2 I need to look at the parent specified , the parent exists in the same table BUT I can not perform the lookup from the BEFORE INSERT ROW LEVEL trigger but I want to ensure at the row level , so if the parent store is closed or parent specifed itself is a child(not permissible) I want to rollback the insert – RAISE_APPLICATION_ERROR.
    Can you please guide me what is the best way to handle the above mentioned conditions .

    I have the following table where it has Foreign Key defined on itself(self reference for parent_id column which can be null or valid site_id)
    create table test_virtual_site
    site_id number CONSTRAINT site_id_pk primary key,
    parent_id number CONSTRAINT parent_site_id_unq UNIQUE ,
    closed_date date default NULL ,
    CONSTRAINT check_self_ref CHECK(parent_site_id <> site_id), --avoid self refernce
    CONSTRAINT check_valid_site foreign key(parent_site_id) references test_virtual_site(site_id)
    I have the following business rules to implement and my problem is related to their implementation
    1)     A check should be made that Site_id specified as parent_id should not be a child of any other store (parent should have its parent_id column as NULL)
    Site_id Parent_id
    1
    2 1
    3 2 =>NOT VALID 2 is a child of another store
    2)     Parent is not closed
    Site_id Parent_id Closed_date
    1 10-May-2005
    3     1 =>NOT VALID 1 is a closed
    3)
    when parent store is closed - updated so at closed_date is not null
    Want to set the parent_id as NULL for the child store.
    OR
    SET the closed_date for child store too same as the parent_store.
    Example
    Site_id Parent_id Closed_date
    1     
    1 2
    Update test_virtual_site
    SET closed_date = sysdate
    Where site_id = 1 ;
    Through Trigger
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1 2 22-Mar-06
    OR
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1
    When I am trying to do the above mentioned through constraints I am running into mutating trigger problem. Can you please guide me what is the best way to handle the above-mentioned scenarios.
    I am aware that I can avoid the 3rd problem using the following
    -- - Initialize an array in the before statement trigger.
    -- - Add the processed rowid to the array in the after row
    -- trigger.
    -- - In the after statement trigger: get each rowid from the
    -- array and process it. When all rowids are processed, clear
    -- the array.
    BUT for 1 and 2 I need to look at the parent specified , the parent exists in the same table BUT I can not perform the lookup from the BEFORE INSERT ROW LEVEL trigger but I want to ensure at the row level , so if the parent store is closed or parent specifed itself is a child(not permissible) I want to rollback the insert – RAISE_APPLICATION_ERROR.
    Can you please guide me what is the best way to handle the above mentioned conditions .

Maybe you are looking for