About rollback

Hello everyone.
A procedure is a trasanction,right?
well if a procedure have exception, will the code in the block between begin and end rollback implicitly?
If it does, what's the difference executing rollback explicitly?
Thanks very much.

Hello everyone.
A procedure is a trasanction,right?Nope.
well if a procedure have exception, will the code in
the block between begin and end rollback
implicitly?Nope.
If it does, what's the difference executing rollback
explicitly?A transaction in Oracle starts with the first update statement (insert, update or delete) and continues on until a COMMIT or ROLLBACK statement.
If there is no commit or rollback before the session disconnects, then the host environment (such as SQLPlus, Toad, Java) has the choice of how to handle the commit or rollback.
There is absolutely no COMMIT or ROLLBACK implied in PL/SQL. Mainly because PL/SQL has nothing to do with SQL ... any SQL statement found in a PL/SQL procedure is actually passed off to the 'SQL engine'. So PL/SQL does nothing other than simply control SQL.
One little known fact is that, in Oracle any DDL (CREATE, ALTER and DROP) automatically does a COMMIT at the beginning of the statement and automatically does a COMMIT or ROLLABCK at the end, depending on success of failure.

Similar Messages

  • A question about ROLLBACK and Unhandled Exceptions in stored subprograms

    Hi,
    Oracle version :   Enterprise Edition Release 11.2.0.1.0 - 64bit
                      OS :   Linux Fedora Core 17 (X86_64)
    At chapter 11 of the online PL/SQL Reference, here is what oracle says about Unhandled Exceptions :
    If a stored subprogram exits with an unhandled exception, PL/SQL does not roll back database changes made by the subprogram.
    I tried the following code:
    code
    HOST clear;
    SET SQLBLANKLINES ON;
    ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
    DROP TABLE tmptab;
    CREATE TABLE tmptab(n NUMBER);
    CREATE OR REPLACE PACKAGE pkg1_pkg
    AUTHID DEFINER
    AS
        MYEXCEPTION EXCEPTION;
        PRAGMA      EXCEPTION_INIT(MYEXCEPTION, -20001);
    END;
    SHOW ERRORS;
    -- This is a subprogram which exists
    -- with an unhandled exception
    CREATE OR REPLACE PROCEDURE mytestProc
    AUTHID DEFINER
    IS  
    BEGIN
        INSERT INTO tmptab(n) VALUES(100);
        -- So this unhandled exception does a ROLLBACK
        -- which cancels the previous INSERT statement
        RAISE pkg1_pkg.MYEXCEPTION;
    END mytestProc;
    SHOW ERRORS;
    BEGIN
        mytestProc();
    END;
    SELECT * FROM tmptab;
    And here is the output
    BEGIN
    ERROR at line 1:
    ORA-20001:
    ORA-06512: at "TRAINING.MYTESTPROC", line 6
    ORA-06512: at line 2
    no rows selected
    The fact that SELECT * FROM tmptab gives: no rows selected indicates that the unhandled exception in the stored subprogram myTestProc did in fact a ROLLBACK for the INSERT statement into the tmptab table.
    So I don't understand why in the documentation it has been mentioned that no ROLLBACK is not done.
    Could anyone kindly make some clarification on this?
    Thanks in advance,
    Regards,
    Dariyoosh

    Hi,
    If a stored subprogram exits with an unhandled exception, PL/SQL does not roll back database changes made by the subprogram.
    What's going on here is that an anonymous block (which is not stored) exits with an unhandled exception, and that does roll back uncommitted transactions.
    I created a procedure to see how many rows are in tmptab:
    CREATE OR REPLACE PROCEDURE tmptab_cnt (in_txt  IN  VARCHAR2)
    AUTHID DEFINER
    AS
         n    PLS_INTEGER;
    BEGIN
         SELECT  COUNT (*)
         INTO    n
         FROM    tmptab;
        dbms_output.put_line (  n
                             || ' rows in tmptab in '
                             || in_txt
    END  tmptab_cnt;
    and called it from your procedure, and also from your anonymous block:
    CREATE OR REPLACE PROCEDURE mytestProc
    AUTHID DEFINER
    IS  
    BEGIN
        INSERT INTO tmptab(n) VALUES(100);
        tmptab_cnt ('mytestProc');
        RAISE pkg1_pkg.MYEXCEPTION;
    END mytestProc;
    SHOW ERRORS;
    BEGIN
        mytestProc();
    EXCEPTION
      WHEN OTHERS THEN
        tmptab_cnt ('anonymous block');
        RAISE;
    END;
    The output from this is:
    Procedure created.
    No errors.
    1 rows in tmptab in mytestProc
    1 rows in tmptab in anonymous block
    BEGIN
    ERROR at line 1:
    ORA-20001:
    ORA-06512: at line 6
    no rows selected
    As you can see, there was 1 row in the table after the procedure returned to the anonymous block.
    Thanks for posting such a clear and complete test script; that really helps.
    How did you format the code, with the green background and the title?

  • Pls help about Rollback and Connection Pooling

    Hello Friends.
    I have some problems abount Rollback & ConnectionPooling.
    If connection pooling is possible with rollback facility??????
    I am giving my code below so pls guide me- i am using MySql and J2EE 1.3.
    try
    /*          Setting auto commit off          */
    con.setAutoCommit(false);
    affectedRow = myStatement.executeUpdate(String qury1);
    affectedRow = myStatement.executeUpdate(String qury2);
    affectedRow = myStatement.executeUpdate(String qury3);
    con.commit();
    }catch(SQLException sqle){
                        try{
                             con.rollback();
                        }catch(Exception e){e.printStackTrace();}
    }finally {
         saveFlg=false;
         try {
              if(myStatement!=null)
              myStatement.close();
         }catch(Exception e){e.printStackTrace();}
    }// finally block complete...
    /* Sample Code Ends*/
    Thanks in advance and Happy New Year

    If connection pooling is possible with rollback facility??????Should be, sure. What problem do you have with it?
    I know very little about MySQL, but I understand it is somewhat "special". Do you have a version of MySQL that has transaction support? Check the MySQL docs: is there some configuration you need to do to enable transactions?

  • How to solve about rollback segment fail to extend?

    I've a transaction about 50,000 records, then process fail in script. the error code is ORA-01562 FAIL TO EXTEND ROLLBACK SEGMENT = num. I'm use oracle database 7.3.4., form 4.5

    It would be better to have several small transactions instead of one huge transaction of 50000 records, like you say. You may use an additional log table to keep the log of how far you've got in processing those 50000 records, and pick up from where you've left in case something goes wrong.
    Anyway, one thing that may help would be to use:
    alter tablespace your_rbs_tablespace
    add datafile ...;
    to have more space for your rollback segment(s).
    Eventually, you may have a large rollback segment and set transaction use huge_rbs, in order to have your huge transaction use that huge rollback segment.
    null

  • In background job  how commit & rollback work works?

    Hello Friends,
         My requirement is, to fetch all sales order items based on some condition and load them into one table say OCC1 in job J1. Now the second requirement is to upload the job information J1 with job name, user name, end date in second table say OCC2 in job J2.
         My question is if there is some error I found while processing job 2 I have to rollback entire work which means I have to remove all records those I have inserted in to table OCC1. Can any one suggest me how to handle such problem? Some how I am able to create two job and update the tables. However, what about rollback work? Whether there is an implicit commit work after every background job? I am working on SAP 4.6C version.
    Thanks,
    Amol C.

    I think by using just ROLL BACK work it will not rollback your first job's data.
    You need to make some mechanism which can delete the data from OCC1 if the J2 got error.
    Regards,
    Naimesh Patel

  • Where can we find information on date and time for rollback on Oracle 11g ?

    Like to find out which log Oracle writes to in order storing information about rollback that is performed. I have an issue wherein, I believe a rollback has occurred after external reports have been generated... hence, the report no longer has the correct information on the state of the system. However, I need to confirm that this is what happened, as I couldn't explain why transactions that were performed prior to the reports were not on the system, yet it was reported in the transaction report. Thank you.

    You should be able to find some rollback information in redo logs with LogMiner: http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/dynviews_2035.htm#i1408263.

  • Question about B1if-Database in SQL-Mgmt-Studio

    Hello,
    We have made some changes in the configuration in SLD.
    We made some more Di-Proxy-Ports and then made Proxygroups for the Databases.
    Nearly every half hour, in SQL-Mgmt Studio we can see this "task" ?
    During the time, this task is online, the Queue-Monitor collects all Jobs... but not more.
    After this Job has finished... B1i begins to work up the jobs.
    Can anyone tell me something about "Rollback Transac" in  B1if-Database ?
    Thanks
    Markus

    Passing the exam and becoming certified are not a matter of simply reading a book or taking a training class. While books and classroom materials as well as in-class training are all important steps in preparing for an exam, experience and research are just as important. I cannot tell you that there are 53 questions on the exam and every single question maps directly back to page 13, paragraph 3 in XX book. However, If you have the classroom material, and you have the list of exam topics, you should be able to find most of the information you need. In some cases, if you are not completely familiar with a specific topic, or you don't feel like the information in the book gives you all the information you need, you may need to do a little additional research. This is all part of preparing for an exam. This process is what makes you successful as a certified professional.
    Your focus seems to be solely on the course materials that you have and what volumes and chapters you should read. I'm trying to give you a different perspective - preparing for an exam is not necessarily about taking one course or reading one book and being ready. You need to review the exam topics and be sure that you are familiar with each topic.
    Regards,
    Brandye Barrington

  • Rollback segment error ORA-1628

    Hellow
    Currently we are working on Oracle 8i database.The database contain spatial data around 10GB.We have a tablespace RBS containing 4 rollback segments. The issue is whenever we try to insert spatial data we get this error message (in the alert file)
    ORA-1628: max # extents 121 reached for rollback segment R01
    Failure to extend rollback segment 2 because of 1628 condition
    FULL status of rollback segment 2 cleared.
    I extended the size of RBS tablespace by adding another datafile, but still it doesn't help.
    Also i found that RBS tablespace is marked as PERMANENT...it means the rollback data does not get flushed out periodically?Also Should this tablespace be temporary? How can i counter this problem?
    Regards
    Sam

    Hi,
    01628, 00000, "max # extents (%s) reached for rollback segment %s"
    // *Cause:  An attempt was made to extend a rollback segment that was
    //          already at the MAXEXTENTS value.
    // *Action: If the value of the MAXEXTENTS storage parameter is less than
    //          the maximum allowed by the system, raise this value. => Alter your RBS and allow more than 121 extents to be created in this RBS.
    Also i found that RBS tablespace is marked as PERMANENT.Yes, it's normal.
    ..it means the rollback data does not get flushed out periodically?No
    Also Should this tablespace be temporary? No, this can't be
    How can i counter this problem?Free advise: RTFM about Rollback Segments! Start here (8i doc) or read the Concepts book.
    Regards,
    Yoann.

  • General - rollback segments

    Been reading manuals, I have few question to clarify about rollback segments ( Lets leave undo tablespace and automatic undo management aside )
    1) Rollback segments can be created in a tablespace - is there a max size/limit which could be specified for a rollback segment to use within a tablespace? - From reading manuals, the storage clause doesnt mention about max size/limt for a rollback segment; is it possible for rollback segment to fill-up tablespace (ummm due to some wired query[read consistency]/transaction) ?
    2) We can create a separate rollback tablespace and have multiple rollback segments.
    If there are 3 user tablespaces (T1/T2/T3), 1 rollback tablespace (RT).
    - I create 1 rollback segment in tablespace T1, T2, T3
    - I create 2 rollback segments in rollback tablespace RT
    A user with "default tablespace T1" when running a transaction, which rollback segment will be used by this user (when rollback segment is not explicitly specified)?
    Oracle-Student

    user11359766 wrote:
    Will the transaction spill over to the second rollback segment (i.e start using the 2nd rollback segment which is available and not being used by any other active transaction) or oracle will return an error since the first rollback segment assigned is filled up and the transaction is still active?This will be applied to both SMU and MMU.
    From the same link above,
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/b_deprec.htm#634941
    For the duration of a transaction, the associated user process writes rollback information only to the assigned rollback segment.I hope its self explanatory that the transaction can't roll over to any other roll back segment once its own gets out of space. In teh case of SMU also, if the undo datafile can't grow, your transaction would be stopped.
    HTH
    Aman....

  • How to find out rollback segment offile or online for pertcular schema????

    how to find rollbacksegment is online or ofline and space information regarding rollbacksegment?
    this is freshely installed 11.5.10.2. defultly how much free space we have????????//
    regards
    dba

    Default rollback segments are always online on database startup.
    if you create any new rollback segments then they will be offline by default during startup.
    for making newly created rollback segments online by default edit your init_sid.ora file and add the name of rollback segment in rollback_segment parameter.
    BTW,why are you concerned about rollback segments,use undo tablespace.

  • Sql to find check Percent of Rollback Segment Used?

    I have the following queries to find information about rollback segments.
    I want the sql to find % of rollback segment used.
    --rollsegs.sql
    select SEGMENT_NAME, OWNER, TABLESPACE_NAME, SEGMENT_ID, status
    from dba_rollback_segs order by segment_name;
    select name, extents, writes, xacts, gets,waits, shrinks, aveactive, status
    from v$rollname n, v$rollstat s
    where n.usn = s.usn
    order by name;
    --rolbstat.sql
    select name, rssize, hwmsize "High", optsize "Opt", wraps, extends, shrinks,
    aveshrink "Aveshr", aveactive "Aveact"
    from v$rollname n, v$rollstat s
    where n.usn = s.usn
    order by name;
    set numformat 999999990;

    DrBurgs, there was a time when your session was assigned a rollback segment that rollback segment held all the updates performed by your session but by Oracle version 8.1 every transaction executed by your session could be assigned to a different rollback segment.
    So every 100,000 or whatever value of N use choose as your commit point could result in a different rollback segment being used. You can use v$rollstat and v$transaction to monitor rollback segment usage while the job is running.
    You stated that you had one rollback segment for every tablespace. There is no relation in Oracle between the number of tablespace and the number of rollback segments you should have.
    You should choose the number of rollback segments to create based on the expected user load and how large a transaction you need to be able to support. For manually defined rollback segments set the initial extent size and the next extent size equal with pctincrease = 0. Then set optimal to the size you would like each rollback segment to be. This size should be large enough that shrinks do not happen often but small enough that one segment that expands will not result in other rollback segments being able to extend. By using uniform extent size you guarentee that every free extent is usable by any other rollback segment that needs to extend.
    With a true warehouse you probably have very little update compared to your select load and the updates are probably load jobs. In this case you may need very few, very large rollback segments to handle the load.
    HTH -- Mark D Powell --

  • Rollback and UNDO

    Hi,
    I'm confuse about Rollback and Undo concepts, can some one explain it to me please?
    Felipe :)

    This is a copy of a previous post I made some time ago:
    There might be confusion while undo and rollback segment terms are used interchangeably in db world. It is due to the compatibility issue of oracle.
    Undo
    Oracle Database must have a method of maintaining information that is used to roll back, or undo, changes to the database. Such information consists of records of the actions of transactions, primarily before they are committed. These records are collectively referred to as undo.
    Undo records are used to:
    * Roll back transactions when a ROLLBACK statement is issued
    * Recover the database
    * Provide read consistency
    * Analyze data as of an earlier point in time by using Flashback Query
    When a ROLLBACK statement is issued, undo records are used to undo changes that were made to the database by the uncommitted transaction. During database recovery, undo records are used to undo any uncommitted changes applied from the redo log to the datafiles. Undo records provide read consistency by maintaining the before image of the data for users who are accessing the data at the same time that another user is changing it.
    Undo vs Rollback
    Earlier releases of Oracle Database used rollback segments to store undo. Oracle9i introduced automatic undo management, which simplifies undo space management by eliminating the complexities associated with rollback segment management. Oracle strongly recommends (Oracle 9i and on words) to use undo tablespace (automatic undo management) to manage undo rather than rollback segments.
    To see the undo management mode and other undo related information of database-
    SQL> show parameter undo
    NAME TYPE VALUE
    undo_management string AUTO
    undo_retention integer 900
    undo_tablespace string UNDOTBS1
    Since the advent of Oracle9i, less time-consuming and suggested way is—using Automatic Undo Management—in which Oracle Database creates and manages rollback segments (now called “undo segments”) in a special-purpose undo tablespace. Unlike with rollback segments, we don’t need to create or manage individual undo segments—Oracle Database does that for you when you create the undo tablespace. All transactions in an instance share a single undo tablespace. Any executing transaction can consume free space in the undo tablespace, and when the transaction completes, its undo space is freed (depending on how it’s been sized and a few other factors, like undo retention). Thus, space for undo segments is dynamically allocated, consumed, freed, and reused—all under the control of Oracle Database, rather than manual management by someone.
    Switching Rollback to Undo
    1. We have to create an Undo tablespace. Oracle provides a function (10g and up) that provides information on how to size new undo tablespace based on the configuration and usage of the rollback segments in the system.
    DECLARE
    utbsiz_in_MB NUMBER;
    BEGIN
    utbsiz_in_MB ;= DBMS_UNDO_ADV.RBU_MIGRATION;
    end;
    CREATE UNDO TABLESPACE UNDOTBS
    DATAFILE ‘/oradata/dbf/undotbs_1.dbf’
    SIZE 100M AUTOEXTEND ON NEXT 10M
    MAXSIZE UNLIMITED RETENTION NOGUARANTEE;
    Note: In undo tablespace creation, “SEGMENT SPACE MANAGEMENT AUTO” can not be set
    2.Change system parameters
    SQL> alter system set undo_retention=900 scope=both;
    SQL> alter system set undo_tablespace=UNDOTBS scope=both;
    SQL> alter system set undo_management=AUTO scope=spfile;
    SQL> shutdown immediate
    SQL> startup
    UNDO_MANAGEMENT is a static parameter. So database needs to be restarted.
    Reference: 10gR2 Administration Guide and Concepts
    Regards,
    Francisco Munoz Alvarez

  • Checking for existing Rollback Segments

    Hello you all,
    Is there a possibility to check for existing rollback segments within procedures?
    Thanks
    Hans

    Hello
    If you just want to be able to find out what rollback segments there are, you can query dba_rollback_segs, which will give you all sorts of info about rollback segments.
    Is that what you need or is it more involved?
    David

  • What is the reason for rollback

    Dear all:
    I have read OpenSPARCT1_Micro_Arch.pdf. But when I read about "2.3.13Rollback Mechanism", I could not catch the
    meaning.
    I have some idea about rollback, but not sure.
    I think, the reason that rollback exists is that a thread must be stall for some reason after D stage,
    but the stage for thread to switch in must be F or S stage. So thread must rollback to F or S stage, until then, it
    can be switched out and wait for next scheduling.
    Is it right? Can anyone help me?
    Thanks

    The rollback described in this section is simply resetting the fetch unit to fetch from the correct address following a stall.
    For example: Suppose the fetch unit fetches a new instruction for a thread from address 0x100 at cycle 0. On the next cycle, this instruction will be at S stage, and the fetch unit will be fetching the next instruction from address 0x104. On the third cycle, the first instruction will be in stage D, and the fetch unit will be fetching the third instruction from address 0x108.
    Now if the first instruction hits a stall condition in stage E, then the first instruction, according to the document, will be returned to the S stage of the pipeline. In addition, the program counter for the thread must be reset to fetch from the proper address so that all instructions are executed in the proper order.
    Think of the pipeline being 4-threads wide in the F and S stages. At the end of the S stage is a multiplexor which selects the thread to issue to the D stage. The rest of the pipeline is only one thread wide. The goal is to keep the later stages of the pipeline busy as much as possible. The fetch unit will fetch instructions for all threads and place them in the instruction buffer (stage S). The instructions will wait in stage S until the thread-switch logic selects that thread. When that thread is selected, the instructions will proceed down the pipeline. Now suppose a load is issued for thread 0, followed by another instruction for the same thread. If in stage M the load misses, then the second instruction cannot complete, so it is flushed from the pipeline, and returned to stage S. In addition, the thread-switch logic will then pick a different thread to issue to the D stage in the next cycle.
    Does this help?

  • Proper use of htmldb_util.set_session_state

    Looking for a way to set a page variable from a trigger.
    I have an app that needs a variable set from within an insert trigger. I would like to let the user see the value of that variable on the page after the insert is complete.
    Can I use htmldb_util.set_session_state for that?
    Thanks.

    See
    Re: HTMLDB_TOOLS by Vikas need some helps about rollback(Urgent !!!)
    The problem is that htmldb_util.set_session_state does a COMMIT and as you know trigger code is not allowed to have a commit (ORA-04092: cannot COMMIT in a trigger)
    What you could try doing is create a little procedure as a autonomous transaction as a wrapper around htmldb_util.set_session_state
    create or replace procedure my_set_session_state
    p_item_name in varchar2,
    p_item_value in varchar2
    is
       PRAGMA AUTONOMOUS_TRANSACTION;
    begin
    htmldb_util.set_session_state(p_item_name,p_item_value);
    end;
    /and call that from your trigger.
    Hope this helps.

Maybe you are looking for

  • How to get multiple values using HttpSession.getAttribute(java.lang.String)

    Hey Guys I'm trying to find a way to get multiple values using the following method HttpSession.getAttribute(java.lang.String) Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a c

  • Error in pricing when doing sourcing in EBP 4.0

    Hello, We're experiencing random errors when doing sourcing in EBP 4.0. The shopping carts don't seem to have any similarities that could launch the error. There has been few cases when the same error has occured when user is creating a shopping cart

  • I've got a SanDisk Cruzer with U3, I want to get it to work with Mozzila Fire, becuase of my bookmarks!

    I've been using Windows on my Computor for a long time but i am starting to use Firefox more! The Question is that i have got a SanDisk Cruzer thumb drive with the U3, and i save all my passwords and bookmoarks on the drive. So the question is where

  • FaceTime with LED

    Hello! Is it good idea to use infrared LED with front camera in new iPhone for illuminating me (for example) when I am talking with someone by FaceTime at night? Thanks and sorry for my bad English.

  • Accessing data from other SAP system

    Hi experts I need to access data from one SAP system from other.  My requirement is , perform applications (programs) in some SAP system, but using/accessing  data from other SAP system . For example, when we press F4 we get the match code (search he