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

Similar Messages

  • How best we can use the Rollback and RollbackAlways mechanism in Visual Studio Release Management Template

    Hello All,
    We need a clarification on Rollback and RollbackAlways in Release template.
    We checked a scenario for Rollback and RollbackAlways:
    In Release Template, we have the first activity as “Configure Application Pool” and then followed by a rollback action of “Create Application Pool”
    and “Create Web Site” then followed by "Code Deployment" via TFS build.
    We tested with 2 scenario’s:
    With App Pool and Web Site already existing: when triggered the build, configure
    app pool succeeded, then Rollback action was skipped (as previous action was successful), finally deploy the code executed (code deployed) and build got succeeded.
    Deleted App Pool and Web Site: when triggered the build, configure app pool failed (as no app pool existed), Rollback action executed (as previous action failed) – created app pool and web site then finally
    deploy the code executed (code deployed)
    But build failed (Error: Configure app pool action failed).
    Ideally the build should succeed as the roll back action got executed and code deployed successfully.
    Please correct us if our understanding is wrong.
    Also, Kindly let us know how best we can use the Rollback and RollbackAlways mechanism in Release Management
    Looking forward for your positive response.
    Thanks in advance.
    Regards,

    Hi Shashank,
    Rollback Always runs if any of the actions in the template failed. Rollback will run if action just above rollback fails or if any of the actions below the Rollback fails.
    Article here (http://www.incyclesoftware.com/2014/03/understanding-rollbacks-release-management/) clearly explains how Rollback and Rollback
    Always work.
    I think you come across this issue since you are using build to do the "code deployment" action. You should use the release template to do that. 
    As far as I know you cannot use Rollback to achieve condition check (App pool exist in your case) action.
    For this you can create your own Power Shell component (which checks if the app pool exist and is not create it) and add it as a tool in RM server (RM Server Inventory).
    Another option is you can follow the workaround in below thread "Answer" quoted below. That is execute Remove app pool regardless if it exist or not (which does not fail) and then create app pool.
    I was able to get it working by removing the app pool which does not fail if it doesn't exist. Removing then creating seems the long way around but it works.
    Flow:
    Remove Application Pool
    Create Application Pool
    https://social.msdn.microsoft.com/Forums/en-US/43bf21c8-e233-4e58-a5a8-2592b78bc466/vs-2013-release-management-create-application-pool-fails-if-it-already-exists?forum=tfsbuild
    Cheers!
    Chaminda

  • Error using Connection.rollback on a pooled connection using XA Driver

    Hi,
    I'm using oracle.jdbc.xa.client.OracleXADataSource version 10.0.1.0.
    <JDBCConnectionPool ConnLeakProfilingEnabled="true"
    ConnProfilingEnabled="true"
    DriverName="oracle.jdbc.xa.client.OracleXADataSource"
    MaxCapacity="5" Name="INFRDV01"
    Password="{3DES}Q0GWuQP0AJoPysLiJNFzLA=="
    Properties="user=INFRA_OWNER"
    RemoveInfectedConnectionsEnabled="false"
    RollbackLocalTxUponConnClose="true" ShrinkingEnabled="false"
    SupportsLocalTransaction="true" Targets="slave-server-1"
    TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:oracle:thin:@db005.india.tavant.com:1521:INFRDV01"/>
    What does this stack trace mean ?
    <log4j:event logger="org.quartz.core.ErrorLogger" date="2005-07-11
    20:10:13,107" timestamp="1121092813107" level="ERROR"
    thread="RedeliveryServiceScheduler_QuartzSchedulerThread">
    <log4j:message><![CDATA[An error occured while scanning for the next trigger to
    fire.]]></log4j:message>
    <log4j:NDC><![CDATA[ipAddress=192.168.139.210 hostname=segu]]></log4j:NDC>
    <log4j:throwable><![CDATA[org.quartz.JobPersistenceException: Couldn't rollback
    jdbc connection. could not use local transaction rollback in a global
    transaction [See nested exception: java.sql.SQLException: could not use local
    transaction rollback in a global transaction]
         at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2192)
         at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1186)
         at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
    * Nested Exception (Underlying Cause) ---------------
    java.sql.SQLException: could not use local transaction rollback in a global
    transaction
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:226)
         at oracle.jdbc.driver.PhysicalConnection.disallowGlobalTxnMode(PhysicalConnection.java:3180)
         at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:990)
         at oracle.jdbc.OracleConnectionWrapper.rollback(OracleConnectionWrapper.java:90)
         at weblogic.jdbc.wrapper.XAConnection.rollback(XAConnection.java:775)
         at weblogic.jdbc.wrapper.JTAConnection.rollback(JTAConnection.java:306)
         at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:2190)
         at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1186)
         at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
    ]]></log4j:throwable>
    </log4j:event>
    I was running into a similar problem where Oracle reported a 'disallowLocalTxnMode' error. A connection pool setting to rollback connection before close resolved that problem.
    This seems to the reverse of that problem.
    Thanks,
    Radhakrishnan

    <Vikas Rawat> wrote in message news:[email protected]..
    java.sql.SQLException: could not use local transaction rollback in a global
    transactionNormally you have to use UserTransaction.rollback() for manual rollback
    instead of calling rollback directly on the connection (if the call is not inside
    a CMT).
    Regards,
    Slava Imeshev

  • Cannot use system rollback segment for non-system tablespace 'TEMP

    Hi everyone!
    I encountered this error: "Cannot use system rollback segment for non-system tablespace 'TEMP"
    So this is what I did to check if the undo stuffs are online.
    SQL> select tablespace_name,status from dba_tablespaces;
    TABLESPACE_NAME                STATUS
    SYSTEM                         ONLINE
    UNDO                           ONLINE
    SYSAUX                         ONLINE
    TEMP                           ONLINE
    LARGEDATA                      ONLINE
    LARGEINDEXES                   ONLINE
    MEDIUMDATA                     ONLINE
    MEDIUMINDEXES                  ONLINE
    SMALLDATA                      ONLINE
    SMALLINDEXES                   ONLINE
    XSMALLDATA                     ONLINE
    TABLESPACE_NAME                STATUS
    XSMALLINDEXES                  ONLINE
    XXSMALLTABS                    ONLINE
    USERS                          ONLINE
    CONVTABLES                     ONLINE
    UNDO_02                        ONLINE
    16 rows selected.
    SQL>  SELECT tablespace_name, sum((bytes/1024)/1024) free FROM DBA_FREE_SPACE gr
    oup by tablespace_name;
    TABLESPACE_NAME                      FREE
    LARGEDATA                      18.3105469
    SMALLDATA                        10.46875
    SYSAUX                           106.5625
    UNDO_02                            67.125
    XXSMALLTABS                    13.0078125
    CONVTABLES                     170.039063
    MEDIUMDATA                             22
    USERS                           37.265625
    SYSTEM                             55.875
    LARGEINDEXES                   30.5175781
    XSMALLINDEXES                    17.34375
    TABLESPACE_NAME                      FREE
    UNDO                             546.9375
    MEDIUMINDEXES                       33.25
    SMALLINDEXES                    31.015625
    XSMALLDATA                     23.6328125
    15 rows selected.
    SQL> select file#,status from v$datafile;
         FILE# STATUS
             1 SYSTEM
             2 ONLINE
             3 ONLINE
             4 ONLINE
             5 ONLINE
             6 ONLINE
             7 ONLINE
             8 ONLINE
             9 ONLINE
            10 ONLINE
            11 ONLINE
         FILE# STATUS
            12 ONLINE
            13 ONLINE
            14 ONLINE
            15 ONLINE
    15 rows selected.
    SQL> select segment_name, tablespace_name, initial_extent,status
      2  from dba_rollback_segs;
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    SYSTEM                         SYSTEM                                 102400
    ONLINE
    _SYSSMU1$                      UNDO                                   131072
    OFFLINE
    _SYSSMU2$                      UNDO                                   131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU3$                      UNDO                                   131072
    OFFLINE
    _SYSSMU4$                      UNDO                                   131072
    OFFLINE
    _SYSSMU5$                      UNDO                                   131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU6$                      UNDO                                   131072
    OFFLINE
    _SYSSMU7$                      UNDO                                   131072
    OFFLINE
    _SYSSMU8$                      UNDO                                   131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU9$                      UNDO                                   131072
    OFFLINE
    _SYSSMU10$                     UNDO                                   131072
    OFFLINE
    _SYSSMU11$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU12$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU13$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU14$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU15$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU16$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU17$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU18$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU19$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU20$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU21$                     UNDO_02                                131072
    OFFLINE
    22 rows selected.How should I be bringing them online?
    I tried this but didn't work for me.
    SQL> alter rollback segment _SYSSMU1$ online;
    alter rollback segment _SYSSMU1$ online
    ERROR at line 1:
    ORA-00911: invalid character
    SQL> alter rollback segment '_SYSSMU1$' online;
    alter rollback segment '_SYSSMU1$' online
    ERROR at line 1:
    ORA-02245: invalid ROLLBACK SEGMENT name
    SQL> alter rollback segment _SYSSMU21$ online;
    alter rollback segment _SYSSMU21$ online
    ERROR at line 1:
    ORA-00911: invalid character
    SQL> alter rollback segment SYSSMU21$ online;
    alter rollback segment SYSSMU21$ online
    ERROR at line 1:
    ORA-01534: rollback segment 'SYSSMU21$' doesn't exist
    SQL> alter rollback segment '_SYSSMU21$' online;
    alter rollback segment '_SYSSMU21$' online
    ERROR at line 1:
    ORA-02245: invalid ROLLBACK SEGMENT name
    SQL> alter rollback segment "_SYSSMU21$" online;
    alter rollback segment "_SYSSMU21$" online
    ERROR at line 1:
    ORA-30017: segment '_SYSSMU21$' is not supported in MANUAL Undo Management mode
    SQL> ALTER SYSTEM SET UNDO_MANAGEMENT=AUTO SCOPE=SPFILE;
    System altered.Should I be bringing every segment online separately? Please guide me.
    Nith
    Edited by: user645399 on Feb 23, 2011 2:52 PM

    SQL> select segment_name, tablespace_name, initial_extent,status
      2  from dba_rollback_segs;
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    SYSTEM                         SYSTEM                                 102400
    ONLINE
    _SYSSMU1$                      UNDO                                   131072
    ONLINE
    _SYSSMU2$                      UNDO                                   131072
    ONLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU3$                      UNDO                                   131072
    ONLINE
    _SYSSMU4$                      UNDO                                   131072
    ONLINE
    _SYSSMU5$                      UNDO                                   131072
    ONLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU6$                      UNDO                                   131072
    ONLINE
    _SYSSMU7$                      UNDO                                   131072
    ONLINE
    _SYSSMU8$                      UNDO                                   131072
    ONLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU9$                      UNDO                                   131072
    ONLINE
    _SYSSMU10$                     UNDO                                   131072
    ONLINE
    _SYSSMU11$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU12$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU13$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU14$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU15$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU16$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU17$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU18$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU19$                     UNDO_02                                131072
    OFFLINE
    _SYSSMU20$                     UNDO_02                                131072
    OFFLINE
    SEGMENT_NAME                   TABLESPACE_NAME                INITIAL_EXTENT
    STATUS
    _SYSSMU21$                     UNDO_02                                131072
    OFFLINEStill undo_02's segments are offline.

  • Error:cannot use system rollback segment for non-system tablespace

    Hi,
    I have created a oracle database 10.2.0 on fedora 9 system. I have created a user and assigned the default tablespace SATYA and given the permissions. But when I create a table in the user I am getting the following error.
    Can anyone help me in rectifying this error.
    ORA-01552: cannot use system rollback segment for non-system tablespace 'SATYA'
    thankyou
    satya

    Undo management is either AUTO or Manual, no local
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/undo.htm#sthref1469
    Since you are using 10g, you are recommended to use Auto undo management
    If you still plan to use manual undo management, make sure you have other non-system rollback segment in place.

  • ORA-01552: cannot use system rollback segment for non-system tablespace

    i try to create a table in new schema test1 and got the following error. please help.
    SQL> create table employer1 as select * from a.employer;
    create table employer1 as select * from a.employer
    ERROR at line 1:
    ORA-01552: cannot use system rollback segment for non-system tablespace 'TEST1'

    Hi,
    This is an example:
    SQL>
    CREATE UNDO TABLESPACE "UNDOTMP"
    DATAFILE 'UNDOTMP.DBF01' SIZE 100M REUSE
    AUTOEXTEND ON NEXT 51200K MAXSIZE 15000M
    ALTER SYSTEM SET undo_tablespace=UNDOTMP SCOPE=BOTH;
    Regards
    David Duenas
    Edited by: David Duenas on Jul 4, 2009 7:33 PM

  • Cannot use system rollback segment for non-system tablespace

    I am getting the below error suddently
    ORA-01552: cannot use system rollback segment for non-system tablespace 'USERS'

    SQL> show parameter undo
    Version : Oracle 10g
    NAME TYPE VALUE
    undo_management string AUTO
    undo_retention integer 10800
    undo_tablespace string UNDO
    SQL>
    SQL> select distinct tablespace_name, status from dba_rollback_segs
    2 ;
    TABLESPACE_NAME STATUS
    SYSTEM ONLINE
    UNDO OFFLINE
    UNDO ONLINE

  • 7.3.4 to 8.1.7  ODMA ERROR : ORA-01552: CANNOT USE SYSTEM ROLLBACK

    Trying to upgrade an old 7.3.4 database running on Aix to 8.1.7 so I can get a compatible export file to allow me to take it to 10gR2.
    I have done some work to get the init.ora file configured with the proper values but the odma fails with the following error:
    drop table dual;
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01552: cannot use system rollback segment for non-system tablespace 'xxx'
    I have other rollback segments defined by my init.ora file and during a normal database startup they are online.
    When I run the 'odma' process it takes the database down and when it brings it up it only has the SYSTEM rollback segment online.
    I know this is an old configuration but anyone have any suggestions?
    I do have "audit_trail = none" in my init file.
    Update:
    Looks like to just do an exp/imp I don't need to worry about going through odma so I am just going to close this post.
    Edited by: user6445925 on 11-Apr-2013 15:23

    Looks like to just do an exp/imp I don't need to worry about going through odma so I am just going to close this post.

  • Why Oracle10g uses System Rollback Segment....????

    Hi ,
    Just a wonder....!!!!
    Why Oracle10g uses System Rollback Segment....and not System undo tablespace... since rollback segment as a method to rollback transactions has been depreciated.....?????
    Thanks.....
    Sim

    System Rollback Segment is reserved for Oracle internal operation.
    I believe it is used only by SYS and programs invoked using SYS authorization manipulating dictionary tables. In which case the complexity has been understood and managed over several generations of Oracle.
    I suspect the system (manual) roillback segment will be very useful when creating a new database, which includes creating whole bunches of tables and views (updating whole bunches of internal tables), at which time no undo segment (or background process for automating that management?) exists.
    Please point to the document or link that says rollback segments are deprecated.
    Even now, manual rollback segments may be of benefit to specific programs and environments that run batch jobs managed by DBA whoy has studied them for a long time under specific circumstances.
    But, just like the various SGA pools should be evaluated and potentially resized when workload changes, the rollback segment configuration needs to be evaluated and potentially resized when workload changes. Few DBAs have the knowledge or skill or time to do so - the automatic adjustments may be the best generic compromise.

  • Is "SET TRANSACTION USE ROLLBACK SEGMENT" only a hint

    I have two users, one makes some inserts in a table.
    The other makes a select which visits many rows.
    I have a big rollback-segment.
    To ensure, both users use this rollback-segment I created a logon-trigger:
    CREATE OR REPLACE TRIGGER a_logon AFTER LOGON
    ON DATABASE
    WHEN ( USER IN ( 'SCOTT', 'BOB' ) )
    BEGIN
    SET TRANSACTION USE ROLLBACK SEGMENT rbs_big;
    END;
    But I still get "snapshot to old" messages from the select, which contains the name off an other rollback-segment in the message.
    The trigger really fires, i tested it by adding an insert-statement to a log-table.
    What`s wrong ?

    The set transaction use rollback segment lasts only until you commit or rollback first time and all other transactions in that session will not be forced to that rbs anymore. Other possible solution could be that other users are accessing same tables / updating them so those sessions can't keep the read consistent image available anymore for your sessions.

  • How can I avoid using rollback segment for batch updates.

    I am currently trying to avoid associating a large amount of space for rollback segment as this gets filled up only during the nightly batch updates. All that space will never be used during the day. Hence want to know if there is any way of avoiding the use of rollback segment at the session level.
    Rajesh

    No, but what you can do is create a large rollback segment to use with your batch job, at the start of your batch job bring the segment online, then use set transaction to use that rollback segment, when the batch job is finished and committed, you can then bring the rollback segment offline.
    If you are really pressed for space, as an alternate plan, you could actually create the large segment before the batch job and drop it after.

  • Rollback a call transaction using CTU_PARAMS

    Is there any combination of CTU_PARAMS and ROLLBACK that can be used to rollback a call txn.  A BAPI is not available for me to use to perform the function I need.

    Hi,
    I dont think there would be any combination available for CTU_PARAMS and ROllback.
    CTU_PARAMS is available only under the following FM`S :
    BDC_RECORD_TRANSACTION
    BDC_RUNNING
    RS_HDBDC_CALL_TC_BATCH_INPUT
    RS_HDBDC_CHANGE_TC_BATCH_INPUT
    Rollback can be done using BAPI_TRANSACTION_ROLLBACK.
    It would be good if you call the Roll back BAPI explicitly instead of doing rollback along with CTU_PARAMS. Make both of them as independent calls.
    Best regards,
    Prashant

  • CMSXDB sample: install.sql - error out, cannot use rollback segment

    I use the setup instruction and had errors when running install.sql at the following part:
    connect cmsadmin/cmsadmin@&tnsname
    SET serveroutput ON
    PROMPT Creating Table 'OTNCMS_PERSONALIZATION'
    CREATE TABLE OTNCMS_PERSONALIZATION (
    USERNAME VARCHAR2(20) NOT NULL,
    RESOURCELOC SYS.XDBURITYPE NOT NULL,
    VIEWTYPE VARCHAR2(40) NOT NULL,
    XSLLOC SYS.XDBURITYPE NOT NULL
    Resulted in error-
    ERROR at line 1:
    ORA-01552: cannot use system rollback segment for non-system tablespace 'USERS'
    Anyone knows why?

    Hi,
    What is the version of Database that is being used ?.
    I guess there must be some issue with the database being used, the archive mode or the UNDO segments. As a workaround, you can remove the following command from install.sql and run the sql script again.
    alter user cmsadmin default tablespace users;Regards
    Elango.

  • Rollback segments using UNDO Tablespace?

    First, I created a database for a vendor with an Undo Tablespace UNDOTBS. Then the vendor requested me to create rollback segments instead. So I created a new tablespace RBSTBS just to hold these segments. When I tried to create the rollback segment using the newly created tablespace RBSTBS, it complained that I am not allowed to use non-system tablespaces.
    So instead, I used the Undo tablespace UNDOTBS to hold the rollback segment. It worked.
    Am I really allowed to use the UNDO tablespace to hold rollback segments? Can't I use normal tablespaces for rollback segments?
    Another thing, the vendor wanted me to create rollback segments of 200MB each. Where do I set this while creating the rollback segment? Is this the INITIAL, NEXT, or OPTIMAL size?
    I know that Oracle recommends using UNDO rather than rollback segments. Is there any advantage in using traditional rollback segments?
    Thanks for any help!

    Advantage with rollback segment is you can force your transaction to use any specific rollback segment, where as with undo you don't have any control. Oracle does it for us.
    Thanks and Regards,
    Satheesh Babu.S
    Bangalore.

  • Trigger and rollback on oracle 9i

    hi,
    i work on oracle 9i.
    in my database i import csv file in en temporary table and make a trigger to update 2 table after insert.
    i want to make a csv file wich contain each not good row.
    i search a way to cancel the first update if the second update is not good
    i try to use a autonomous transaction but there is an error...maybe you can help me and give me a solution to my probleme.
    my trigger's code
    declare
    gache NUMBER;lieu NUMBER;reference NUMBER;test UTL_FILE.FILE_TYPE; erreur NUMBER;
    v_file UTL_FILE.FILE_TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
    commit;
    SELECT id_lieu INTO lieu
    FROM TBL_LIEU
    WHERE est_xgs_lieu=1;
    IF :NEW.dateImpr IS NOT NULL THEN
    IF :NEW.preImpcode1 IS NOT NULL AND :NEW.preImpQt1>0 THEN
    SELECT id_reference,POURCENTAGE_GACHE_REFERENCE INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode1
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
    INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
    VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt1*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt1*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
         END IF;
    IF :NEW.preImpcode2 IS NOT NULL AND :NEW.preImpQt2>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode2
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt2*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt2*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
         END IF;
    IF :NEW.preImpcode3 IS NOT NULL AND :NEW.preImpQt3>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode3
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt3*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt3*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    END IF;
    IF :NEW.preImpcode4 IS NOT NULL AND :NEW.preImpQt4>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode4
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp,ROUND(:NEW.preImpQt4*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt4*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    END IF;
    IF :NEW.preImpcode5 IS NOT NULL AND :NEW.preImpQt5>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode5
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt5*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt5*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF reference IS NULL THEN
         erreur:=1;
         end if;
    END IF;
    END IF;
    IF :NEW.dateMsp IS NOT NULL THEN
    IF :NEW.encartCode1 IS NOT NULL AND :NEW.encartQt1>0 THEN
         SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode1;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp,:NEW.encartQt1,'Impression',lieu,reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt1
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.encartCode2 IS NOT NULL AND :NEW.encartQt2>0 THEN
    SELECT id_reference, pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode2;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
         VALUES(:NEW.dateExp, :NEW.encartQt2, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt2
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.encartCode3 IS NOT NULL AND :NEW.encartQt3>0 THEN
         SELECT id_reference , pourcentage_gache_reference INTO reference, gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode3;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp, :NEW.encartQt3, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt3
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF :NEW.encartCode4 IS NOT NULL AND :NEW.encartQt4>0 THEN
         SELECT id_reference , pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode4;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp,:NEW.encartQt4, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt4
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF :NEW.encartCode5 IS NOT NULL AND :NEW.encartQt5>0 THEN
         SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode5;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateExp,:NEW.encartQt5, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt5
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.codeEnv IS NOT NULL and :NEW.nbPlis>0 THEN
         SELECT id_reference INTO reference
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.codeEnv
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateMsp, :NEW.nbPlis, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.nbPlis
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    END IF;
    END IF;
    EXCEPTION
    when NO_DATA_FOUND then
    v_file:= UTL_FILE.FOPEN ('DOSSIER_EXP','rejet_stock'||to_char(sysdate,'DD-MM-YYYY-hh24-mi-ss')||'.csv','A',32767);
    UTL_FILE.PUT_LINE(v_file,:new.FLUXIDCLIENT||';'||:new.FLUXDATECREATION||';'||:new.NOMCLIENT||';'||:new.APPLILABEL||';'
    ||:new.LOTID||';'||:new.NUMEROBATCHSOUSLOT||';'||:new.FILIERE||';'||:new.DATEIMPR||';'||:new.DATEMSP||';'
    ||:new.DATEEXP||';'||:new.NBPAGES||';'||:new.NBPLIS||';'||:new.ISTEMPOST||';'||:new.SSLOTSTATUT||';'
    ||:new.NOMIMPRIMANTE||';'||:new.MODEIMPRESSION||';'||:new.ENCARTCODE1||';'||:new.ENCARTCODE2||';'||:new.ENCARTCODE3||';'
    ||:new.ENCARTCODE4||';'||:new.ENCARTCODE5||';'||:new.ENCARTQT1||';'||:new.ENCARTQT2||';'||:new.ENCARTQT3||';'
    ||:new.ENCARTQT4||';'||:new.ENCARTQT5||';'||:new.PREIMPCODE1||';'||:new.PREIMPCODE2||';'||:new.PREIMPCODE3||';'
    ||:new.PREIMPCODE4||';'||:new.PREIMPCODE5||';'||:new.PREIMPQT1||';'||:new.PREIMPQT2||';'||:new.PREIMPQT3||';'
    ||:new.PREIMPQT4||';'||:new.PREIMPQT5||';'||:new.CODEENV||';');
    UTL_FILE.FFLUSH (v_file);
    UTL_FILE.FCLOSE(v_file);
    erreur:=1;
    ROLLBACK;
    end;

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

Maybe you are looking for

  • How do I create podcast links that open automatically in iTunes?

    I want to create different podcasts and distribute them via emails to my friends. I want to make it as simple as possible, so that my friends can click on the link to my feed, and have iTunes open automatically, and subscribe to my podcast without ta

  • A Self-Contained JRE

    Hi, I am developing an incident response kit in Java. The kit creates new processes for each forensic test using Runtime.getRuntime().exec(cmd). This kit will be part of a larger project to perform remote forensic analysis of vulnerable machines on a

  • Order events by date in left panel ?

    I have just installed the trial version of aperture 3. I have imported my iPhoto library of 155gb with many events from a round the world trip. When I click on iPhotoLibrary and select browser I can see all my events in the main viewer panel and then

  • QUALITY -  .MOVs  to Encore, but video quality horrible -- DVD

    Hello, I am a newbie to Encore and video processing, alike - I'm hoping that someone can enlighten me in the ways of High Definition/working with conversion to DVD in Encore. I'm currently working on making a DVD with a main menu which links to a mai

  • Do I have to use Iweb's plain hyperlinks?

    I want to add my own hyperlinks/menu bar using different colors and shapes like I have seen on other pages but can't find instructions on how do accomplish this in the program.