Rollback in  a trigger

Using a trigger on update.
In the code for the trigger I want to do the following:
Update a table in another database on the same server using a database link.
Update a table in another database on a remote server using a database link.
Delete the row that is currently being updated.
If any errors occur, I have:
EXCEPTION
     WHEN OTHERS
     THEN ROLLBACK
The idea is that if any of the three actions fail, then an exception will occur and the previous actions would roll back.
If I take down the remote server, I would expect that the error handling would come into play. It’s not. The changes on the local database have occurred. Am I doing something wrong, flawed logic?

Thanks for the help Kamal.
Not real familiar with autonomous transaction, but you have to define that in the trigger, right?
I'm including the code below. If I'm not using autonomous transaction, is the rollback in the error handling causing my problem? Should I just remove the whole error handling portion?
CREATE OR REPLACE TRIGGER F_SW.TR_CENTERA_REPL
AFTER INSERT
ON F_SW.REPLICATION_VALUES
DECLARE
rowRV f_sw.replication_values%ROWTYPE;
cursor c1 is select f_docnumber, fnp_clipid, fnp_archive
from f_sw.replication_values;
BEGIN
Open c1;
loop
fetch c1 into rowRV;
exit when c1%NOTFOUND;
update DOCTABA@IDBDEV2
set A60 = rowRV.fnp_archive, A61 = rowRV.fnp_clipid
where F_DOCNUMBER = rowRV.f_docnumber;
--second, update the local FOCUS FIIV table
update FIIV_INDEX_VAL@FIT1
set CENTERA_ARCH_D = TO_DATE('1/1/1970', 'mm/dd/yyyy') + rowRV.fnp_archive,
CENTERA_ADDR_X = rowRV.fnp_clipid
where DOC_ID_N = rowRV.f_docnumber;
--finally, delete this row from replication values
delete
from REPLICATION_VALUES
where F_DOCNUMBER = rowRV.f_docnumber;
end loop;
--clean up
close c1;
EXCEPTION
WHEN others
THEN rollback;
END;

Similar Messages

  • Rollbacking in A Trigger

    Hi guys!!
    again I need some help.
    I have a table t. I am writing a trigger that
    fires when a tuple is inserted in t. This trigger
    should check some condition and if that is not
    satisfied it should disallow the insertion in
    t. But if I put rollback in the trigger, i am
    getting error that "rollback not allowed in a trigger";
    I am using Oracle 9i and attaching my code here for
    reference.
    create or replace trigger trans_trigger
    before insert on transactions
    for each row
    declare
         qty_oh products.qty_on_hand%type;
    begin
    -- get qty on hand for this product
         select qty_on_hand into qty_oh from products
         where products.pid = :new.pid;
    -- if quantity on hand < purchased qty
    -- then disallow insertion
         if (not :new.qty_purchased <= qty_oh) then
         dbms_output.put_line ('Insufficient Quantity in Stock');
    -- here i tried to use rollback;
         end if;
    end;
    any way to deal with this?
    Thanks
    Bhavin

    Defining Your Own Error Messages: Procedure RAISE_APPLICATION_ERROR
    The procedure RAISE_APPLICATION_ERROR lets you issue user-defined ORA- error messages from stored subprograms. That way, you can report errors to your application and avoid returning unhandled exceptions.
    To call RAISE_APPLICATION_ERROR, use the syntax
    raise_application_error(error_number, message[, {TRUE | FALSE}]);
    where error_number is a negative integer in the range -20000 .. -20999 and message is a character string up to 2048 bytes long. If the optional third parameter is TRUE, the error is placed on the stack of previous errors. If the parameter is FALSE (the default), the error replaces all previous errors. RAISE_APPLICATION_ERROR is part of package DBMS_STANDARD, and as with package STANDARD, you do not need to qualify references to it.
    An application can call raise_application_error only from an executing stored subprogram (or method). When called, raise_application_error ends the subprogram and returns a user-defined error number and message to the application. The error number and message can be trapped like any Oracle error.
    In the following example, you call raise_application_error if an employee's salary is missing:
    CREATE PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER) AS
    curr_sal NUMBER;
    BEGIN
    SELECT sal INTO curr_sal FROM emp WHERE empno = emp_id;
    IF curr_sal IS NULL THEN
    /* Issue user-defined error message. */
    raise_application_error(-20101, 'Salary is missing');
    ELSE
    UPDATE emp SET sal = curr_sal + amount WHERE empno = emp_id;
    END IF;
    END raise_salary;
    The calling application gets a PL/SQL exception, which it can process using the error-reporting functions SQLCODE and SQLERRM in an OTHERS handler. Also, it can use the pragma EXCEPTION_INIT to map specific error numbers returned by raise_application_error to exceptions of its own, as the following Pro*C example shows:
    EXEC SQL EXECUTE
    /* Execute embedded PL/SQL block using host
    variables my_emp_id and my_amount, which were
    assigned values in the host environment. */
    DECLARE
    null_salary EXCEPTION;
    /* Map error number returned by raise_application_error
    to user-defined exception. */
    PRAGMA EXCEPTION_INIT(null_salary, -20101);
    BEGIN
    raise_salary(:my_emp_id, :my_amount);
    EXCEPTION
    WHEN null_salary THEN
    INSERT INTO emp_audit VALUES (:my_emp_id, ...);
    END;
    END-EXEC;
    This technique allows the calling application to handle error conditions in specific exception handlers.
    Joel P�rez

  • 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

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE)
    Sequence creation:
    CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE START WITH 6000 INCREMENT BY 1 MINVALUE 6000 MAXVALUE 6999 NOCACHE NOCYCLE NOORDER ;
    Trigger creation:
    CREATE OR REPLACE TRIGGER TEST_TABLE INSERT BEFORE INSERT ON TEST_TABLE FOR EACH ROW
    DECLARE
    pkValue NUMBER;
    BEGIN
    pkValue := 0;
    Select TEST_TABLE_SEQUENCE.NextVal into pkValue from dual;
    :NEW.TEST_KEY := pkValue;
    END TEST_TABLE_INSERT;
    We have created a snapshot of the schema on mobile server, synchronized the data with the client (Win32 for testing purpose).
    The trigger works fine on the server, but when I run the same query on the lite database with msql it gives me an error:
    [POL-3221] null key in primary index
    I was wondering if Sequence generation and Triggers are supported on Oracle 9i lite database ? Or am I missing out something ??
    Any information/ help is appreaciated
    Thanks
    Neeraj

    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

  • Getting all_tab_columns.data_default in a ddl trigger

    Under 10.1.0.3 I'm working on an AFTER CREATE or ALTER on DATABASE system trigger, and I'm querying all_tab_columns in the trigger body. It seems that if the trigger fires in response to DDL that modifies a column's default value, then all_tab_columns.data_default is giving me the column's old default. I want to get the current default value. If I create the table or add a column, then, in the resulting fire of the system trigger, all_tab_columns.data_default seems to be correct.
    Is this documented behavior? Should I be looking somewhere (or somewhen) else for the column default?

    Thanks.
    I tried working around this by putting my code into a procedure, and then using the DDL trigger to create a job that runs the code. My idea was to defer the all_tab_columns query until after the DDL trigger was done, and thus get a clean look at the data dictionary.
    I put what looks like the appropriate dbms_scheduler calls into the trigger, but when I then execute DDL to fire the trigger I get "ORA-04092: cannot in a trigger"
    The doc for this error number says that I am trying to commit or rollback in a trigger, but I'm not explicitly doing that. Also, the error message is supposed to have either the word "commit" or the word "rollback" in the message to tell me what I am doing. Instead, though, the error message just has a space there.
    Maybe I'll start a TAR and see if 10.1.0.3 can get appended to the growing list of versions tied to this bug.

  • ORA-04091: table is mutating, trigger/function may no

    Hi all,
    I'm trying to create a trigger, but I got the following:
    ERROR at line 1:
    ORA-04092: cannot ROLLBACK in a trigger
    ORA-06512: at "PKG_PROJ", line 63
    ORA-04091: table TBL_DATA is mutating, trigger/function may not see it
    ORA-06512: at "T$D_INS_TDATA", line 4
    ORA-04088: error during execution of trigger 'T$D_INS_TDATA'My trigger is:
    CREATE OR REPLACE TRIGGER T$D_INS_TDATA
           AFTER INSERT ON TBL_DATA
           FOR EACH ROW
    DECLARE
    BEGIN
         PKG_PROJ.P$INSERT(:NEW.ID);
         COMMIT;
    END;
    /Where meu procedure is:
           PROCEDURE P$INSERT
               P_ID      IN TBL_DATA.ID%TYPE
           AS
           BEGIN
                INSERT INTO TBL_DETAIL
                    ID_DETAIL,           DT_DETAIL, OBS,
                SELECT SEQ_DETAIL.NEXTVAL, SYSDATE, 'INSERT TRIGGER TEST'
                FROM TBL_DATA DC
                AND   DC.ID    =  P_ID
                COMMIT WORK;
            EXCEPTION
                     WHEN OTHERS THEN
                         ROLLBACK;
                         RAISE_APPLICATION_ERROR(-20102, 'PKG_PROJ.P$INSERT: ' || SQLERRM);
           END P$INSERT;Somebody can help me???
    thanx!!!! :-)

    Tad,
    I believe you're performing SELECT on the triggering table in the PL/SQL block. In simple words, you're trying to change the information of a table the TRIGGER is created for and you're trying to read data from the same table.
    I suggest that you use PL/SQL pragma autonomous_transaction to resolve this, for as per Oracle documentation "The AUTONOMOUS_TRANSACTION pragma instructs the PL/SQL compiler to mark a routine as autonomous (independent). An autonomous transaction is an independent transaction started by another transaction, the main transaction. Autonomous transactions let you suspend the main transaction, do SQL operations, commit or roll back those operations, then resume the main transaction."
    Furthermore, you can also refer to the following discussion by Thomas Kyte for further understanding of mutating tables:
    Avoiding Mutating Tables
    http://asktom.oracle.com/tkyte/Mutate/
    Hope this helps.
    Regards,
    Naveed.

  • Roll back deleted record in a trigger

    Hi,
    The question is How can i prevent a record that has a certain value from being deleted using a Before trigger?
    i tryed
    If :old.rowid=v then
    roll back;
    end if;
    id does not work .
    Any Help will be appreciated.

    You can neer use a rollback in a trigger. You can just make a
    check on your value and delete it only for those tou want.

  • Wf_event.raise : database trigger : ORA-04092 : differs from documented behavior

    Product Management :
    Calling wf_event.raise from an after insert row trigger produces ORA-04092. This is exactly opposite from the supposed documented behavior.
    Thanks in advance for your attention to this matter. Needless to say, raising business events from fundamental database activities like inserting & updating rows is critically important.
    Version : 2.6.2 as distributed with 9iAS 9.0.2.0.1 on Win2K
    Error message :
    ORA-04092: cannot ROLLBACK in a trigger
    ORA-06512: at "OWF_MGR.WF_EVENT", line 830
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-06512: at "OWF_MGR.WF_EVENT", line 451
    ORA-06512: at "CASEINT.CG$AIR_FOLDERS", line 7
    ORA-04088: error during execution of trigger 'CASEINT.CG$AIR_FOLDERS'
    From the Oracle Workflow Guide :
    "For environments such as database triggers or distributed
    transactions that do not allow savepoints, the Workflow Engine
    automatically traps Savepoint not allowed errors and defers
    the execution of the activity to the background engine."

    The Business Event System and Workflow Engine are two different components, hence the documentation is actually
    correct as it refers to the 'Workflow Engine' specifically.
    A fix is currently being developed for the problem that you are encountering and will be included in Workflow Standalone
    Version 2.6.3 (iAS 9.0.4).
    There is also a Bug raised for this issue in Workflow 2.6.2 - Bug 2427354 - if you wish to escalate this then please contact
    Oracle Support to raise a TAR against this Bug.
    As a workaround in the meantime you could launch a deferred workflow process that raises the required event.

  • Commit/Rollback on Tab pages

    I have three tab pages
    1st tab page called master_detal_page. It is base block bound to tables.
    2nd tab page called Keyword_page. It is not bound to the table.
    3rd tab page called Exit_page. It will popup dialog box ask for save the changes. commit,rollback,exit_form on trigger when-page-change.
    I encountered problems that I was unabled ROLLBACK or COMMIT the change I made on 1st or 2nd pages. When I refresh tab pages always display back to orginal records.
    Please help me with any technical to solve it. Thanks
    Trigger: WHEN-TAB-PAGE-CHANGED
    DECLARE
    v_result VARCHAR2(30);
    BEGIN
    IF :SYSTEM.TAB_NEW_PAGE= 'EXIT_PAGE' THEN
    v_result := FUNCTION_DISPLAY_MSG_BOX('Do you want to
    save changes before existing');
    IF v_result = 'YES' THEN
    COMMIT;
    GO_BLOCK('BLK_1ST_PAGE');
    ELSIF v_result = 'NO' THEN
    ROLLBACK;
    GO_BLOCK('BLK_1ST_PAGE');
    ELSE
    EXIT_FORM(NO_VALIDATE);
    END IF;
    END;

    what is the error you got? go to menu/display error to see if any.
    Then it likely you got saving issue with your master-detail block.
    can you save with only master block data? but cannot save if both blocks have new data?
    if yes, then you may add when-validate-record trigger to master and detail blocks, with code forms_ddl('post');
    then see it makes difference.

  • No commit in trigger

    I have seen that there is no commit reqd. in trigger, the statements get auto-committed.
    Is it true?
    I hope, my question is clear. Please help in solving the doubt.
    regards.

    The trigger code executes in the same transaction the
    actula DML statements is running. Any commit or
    rollback to the actual DML statement equally applies
    to the statements in the triggerUnless trigger use AUTONOMOUS TRANSACTION - in this case you have to commit or rollback inside the trigger.

  • How to run batch file using trigger?

    Hi, i am trying run a batch file using a trigger on a table.
    say i have a table XYZ(col_1 varchar2 primary key, col_2 varchar2)
    the values of col_2 keeps changing and col_1 are constant
    whenever the value of col_2 in any row changes from "on" to "off" i want to run a batch file C:\Users\ABC\Desktop\test.bat
    i did some searching but couldn't find any solution. Thanks in advance
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

    >
    the script will be started around 60-70 times a day
    >
    No - as marwim said the script will be executed every time the trigger is fired. And that trigger, depending on how it is written, might be fired several times for the same transaction.
    And if the trigger is fired the script will be executed even if the transaction that caused the trigger to fire issues a ROLLBACK.
    Triggers are non-transactional. You need to clearly define the business rules for when the script should run. Should it run only when the transaction is COMMITTED? Or should it run if the transaction executes even if the transaction performs a ROLLBACK?
    A trigger is the wrong solution for your problem.
    Please clarify what the business rules are that should control the execution of the script.

  • Avoid an insertion in a table

    Good morning!!
    I'm trying to create a trigger in order to avoid some undesiderable insertions in a table of my DB. I check some basic rules of the data and I would like that in some cases the insertion won't be committed, but if I use a raise_application_error in my trigger, an error appears informing me that the number of the exception is out of range, and I can't make a rollback inside the trigger.
    I've tried to insert the wrong data in other table and program other after insert trigger on this auxiliary table to drop the incorrect data, but without possitive result. The code of both triggers is as follow:
    -- Table where I want to avoid the insertions: TABLE1
    -- Auxiliar table: TABLE_AUX
    CREATE OR REPLACE TRIGGER CHECK_CONDITIONS
    AFTER INSERT
    ON TABLE1
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    EXISTE NUMBER;
    PREV_DATA1 NUMBER;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    SELECT COUNT(*),DATA1 INTO EXISTE,PREV_DATA FROM TABLE1 WHERE DATA2 = :NEW.DATA2 GROUP BY DATA1;
    IF EXISTE = 1 THEN
    dbms_output.put_line('Mother Word '||:new.mother_word ||' existente en BD');
    IF PREV_DATA <> :NEW.DATA1 THEN
         INSERT INTO TABLE_AUX VALUES(:NEW.DATA1,:NEW.DATA2);
         COMMIT;
         END IF;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    WHEN OTHERS THEN
         dbms_output.put_line(to_char(sqlcode)||': '||to_char(sqlerrm));
    END CHECK_CONDITIONS;
    CREATE OR REPLACE TRIGGER DELETE_BAD_DATA
    AFTER INSERT
    ON TABLE_AUX
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    DELETE FROM TABLE1 WHERE DATA1 = :NEW.DATA1 AND DATA2 = :NEW.DATA2;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
         dbms_output.put_line(to_char(sqlcode)||to_char(sqlerrm));
    END DELETE_BAD_DATA;
    Any help would be useful.
    Thanks in advance.
    Isabel

    One thing if you want to do a rollback or commit inside a trigger is using autonomous transaction inside a trigger..Please find the sample code for that which might be useful in your case
    CREATE OR REPLACE TRIGGER t_autonomous_tx
    BEFORE INSERT
    ON person
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    INSERT INTO audit_log
    (chng_when, commentcol)
    VALUES
    (SYSDATE, 'Reporting an error');
    COMMIT;
    END t_autonomous_tx;

  • Oracle SQL and PL/SQL interview questions.

    Can anyone forward me all Oracle SQL and PL/SQL Interview questions and answers asap.
    Many Thanks.
    Bba

    Dear Pal
    I not sure all the all answers are correct. I got one mail couple yrs back. I am just sharing mail contents. Kindly keep question and compare answers.
    1 Which is more faster - IN or EXISTS?
    EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.
    2 Which datatype is used for storing graphics and images?
    LONG RAW data type is used for storing BLOB's (binary large objects).
    3 When do you use WHERE clause and when do you use HAVING clause?
    HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.
    4 What WHERE CURRENT OF clause does in a cursor?
    LOOPSELECT num_credits INTO v_numcredits FROM classesWHERE dept=123 and course=101;UPDATE studentsSET current_credits=current_credits+v_numcreditsWHERE CURRENT OF X;END LOOPCOMMIT;END;
    5 What should be the return type for a cursor variable.Can we use a scalar data type as return type?
    The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE
    6 What is use of a cursor variable? How it is defined?
    A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type (like a pointer in C).Declaring a cursor variable:TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the types of the select list that will eventually be returned by the cursor variable.
    7 What is the purpose of a cluster?
    Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.
    8 What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?
    1,000,00
    9 What is syntax for dropping a procedure and a function .Are these operations possible?
    Drop Procedure procedure_nameDrop Function function_name
    10 What is OCI. What are its uses?
    Oracle Call Interface is a method of accesing database from a 3GL program. Uses--No precompiler is required,PL/SQL blocks are executed like other DML statements. The OCI library provides· -functions to parse SQL statemets· -bind input variables· -bind output variables· -execute statements· -fetch the results
    11 What is difference between UNIQUE and PRIMARY KEY constraints?
    A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.
    12 What is difference between SUBSTR and INSTR?
    SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDEINSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')
    13 What is difference between SQL and SQL*PLUS?
    SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.
    14 What is difference between Rename and Alias?
    Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.
    15 What is difference between a formal and an actual parameter?
    The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters
    16 What is an UTL_FILE.What are different procedures and functions associated with it?
    UTL_FILE is a package that adds the ability to read and write to operating system files. Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.
    17 What is a view ?
    A view is stored procedure based on one or more tables, it’s a virtual table.
    18 What is a pseudo column. Give some examples?
    It is a column that is not an actual column in the table.eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL.
    19 What is a OUTER JOIN?
    Outer Join--Its a join condition used where you can query all the rows of one of the tables in the join condition even though they don’t satisfy the join condition.
    20 What is a cursor?
    Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.
    21 What is a cursor for loop?
    Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor's record.
    22 What are various privileges that a user can grant to another user?
    · SELECT· CONNECT· RESOURCES
    23 What are various constraints used in SQL?
    · NULL· NOT NULL· CHECK· DEFAULT
    24 What are ORACLE PRECOMPILERS?
    Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA.The Precompilers are known as Pro*C,Pro*Cobol,...This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.The output must be compiled and linked with this library to creater an executable.
    25 What are different Oracle database objects?
    · TABLES· VIEWS· INDEXES· SYNONYMS· SEQUENCES· TABLESPACES etc
    26 What are different modes of parameters used in functions and procedures?
    · IN· OUT· INOUT
    27 What are cursor attributes?
    · %ROWCOUNT· %NOTFOUND· %FOUND· %ISOPEN
    28 What a SELECT FOR UPDATE cursor represent. [ANSWER]SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT] The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.
    29 There is a string 120000 12 0 .125 , how you will find the position of the decimal place?
    INSTR('120000 12 0 .125',1,'.')output 13
    30 There is a % sign in one field of a column. What will be the query to find it?
    '' Should be used before '%'.
    31 Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
    SELECT customer_no, payments from customer C1
    WHERE 3<=(SELECT COUNT(*) from customer C2
    WHERE C1.payment <= C2.payment)
    32 minvalue.sql Select the Nth lowest value from a table
    select level, min('col_name') from my_table where level = '&n' connect by prior ('col_name') <
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second lowest salary:
    -- select level, min(sal) from emp
    -- where level=2
    -- connect by prior sal < sal
    -- group by level
    33 maxvalue.sql Select the Nth Highest value from a table
    select level, max('col_name') from my_table where level = '&n' connect by prior ('col_name') >
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second highest salary:
    -- select level, max(sal) from emp
    -- where level=2
    -- connect by prior sal > sal
    -- group by level
    34 How you will avoid your query from using indexes?
    SELECT * FROM emp
    Where emp_no+' '=12345;
    i.e you have to concatenate the column name with space within codes in the where condition.
    SELECT /*+ FULL(a) */ ename, emp_no from emp
    where emp_no=1234;
    i.e using HINTS
    35 How you will avoid duplicating records in a query?
    By using DISTINCT
    36 How you were passing cursor variables in PL/SQL 2.2?
    In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2, the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter.
    37 How you open and close a cursor variable.Why it is required?
    OPEN cursor variable FOR SELECT...Statement
    CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used. In order to free the resources used for the query CLOSE statement is used.
    38 How will you delete duplicating rows from a base table?
    delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); or
    delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv);
    39 How do you find the numbert of rows in a Table ?
    A bad answer is count them (SELECT COUNT(*) FROM table_name)
    A good answer is :-
    'By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES).
    The best answer is to refer to the utility which Oracle released which makes it unnecessary to do ANALYZE TABLE for each Table individually.
    40 Find out nth highest salary from emp table
    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    For Eg:-
    Enter value for n: 2
    SAL
    3700
    41 Display the records between two range?
    select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);
    42 Display the number value in Words?
    SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))
    from emp;
    the output like,
    SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
    800 eight hundred
    1600 one thousand six hundred
    1250 one thousand two hundred fifty
    If you want to add some text like, Rs. Three Thousand only.
    SQL> select sal "Salary ",
    (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
    "Sal in Words" from emp
    Salary Sal in Words
    800 Rs. Eight Hundred only.
    1600 Rs. One Thousand Six Hundred only.
    1250 Rs. One Thousand Two Hundred Fifty only.
    43 Display Odd/ Even number of records
    Odd number of records:
    select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
    Output:-
    1
    3
    5
    Even number of records:
    select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
    Output:-
    2
    4
    6
    44 Difference between procedure and function.
    Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.
    45 Difference between NO DATA FOUND and %NOTFOUND
    NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.
    46 Difference between database triggers and form triggers?
    Data base trigger(DBT) fires when a DML operation is performed on a data base table. Form trigger(FT) Fires when user presses a key or navigates between fields on the screen
    Can be row level or statement level No distinction between row level and statement level.
    Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms.
    Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.
    Can cause other database triggers to fire.Can cause other database triggers to fire, but not other form triggers.
    47 Difference between an implicit & an explicit cursor.
    PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including quries that return only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop.
    Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.
    48 Can you use a commit statement within a database trigger?
    No.
    49 Can the default values be assigned to actual parameters?
    Yes
    50 Can cursor variables be stored in PL/SQL tables.If yes how. If not why?
    No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.
    51 Can a primary key contain more than one columns?
    Yes
    52 Can a function take OUT parameters. If not why?
    No. A function has to return a value,an OUT parameter cannot return a value.
    53 What are various joins used while writing SUBQUERIES?
    Self join-Its a join foreign key of a table references the same table. Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don't satisfy the join condition.
    Equi-join--Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.
    54 Differentiate between TRUNCATE and DELETE
    TRUNCATE deletes much faster than DELETE
    TRUNCATE
    DELETE
    It is a DDL statement It is a DML statement
    It is a one way trip,cannot ROLLBACK One can Rollback
    Doesn't have selective features (where clause) Has
    Doesn't fire database triggers Does
    It requires disabling of referential constraints. Does not require
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    31 Name the tables where characteristics of Package, procedure and functions are stored ?
    User_objects, User_Source and User_error.
    32 Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
    It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
    33 How packaged procedures and functions are called from the following?
    a. Stored procedure or anonymous block
    b. an application program such a PRC C, PRO COBOL
    c. SQL *PLUS
    a. PACKAGE NAME.PROCEDURE NAME (parameters);
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    EXEC SQL EXECUTE
    b.
    BEGIN
    PACKAGE NAME.PROCEDURE NAME (parameters)
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    END;
    END EXEC;
    c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any
    out/in-out parameters. A function can not be called.
    34 How many types of database triggers can be specified on a table ? What are they ?
    Insert Update Delete
    Before Row o.k. o.k. o.k.
    After Row o.k. o.k. o.k.
    Before Statement o.k. o.k. o.k.
    After Statement o.k. o.k. o.k.
    If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
    If WHEN clause is specified, the trigger fires according to the returned Boolean value.
    35 Give the structure of the procedure ?
    PROCEDURE name (parameter list.....)
    is
    local variable declarations
    BEGIN
    Executable statements.
    Exception.
    exception handlers
    end;
    36 Give the structure of the function ?
    FUNCTION name (argument list .....) Return datatype is
    local variable declarations
    Begin
    executable statements
    Exception
    execution handlers
    End;
    37 Explain the usage of WHERE CURRENT OF clause in cursors ?
    WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor.
    Database Triggers
    38 Explain the two type of Cursors ?
    There are two types of cursors, Implicit Cursor and Explicit Cursor.
    PL/SQL uses Implicit Cursors for queries.
    User defined cursors are called Explicit Cursors. They can be declared and used.
    39 Explain how procedures and functions are called in a PL/SQL block ?
    Function is called as part of an expression.
    sal := calculate_sal ('a822');
    procedure is called as a PL/SQL statement
    calculate_bonus ('A822');
    Programmatic Constructs
    Last Update: September 06, 2004
    1 What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
    Procedures and Functions,Packages and Database Triggers.
    2 What are the differences between Database Trigger and Integrity constraints ?
    A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table.
    A trigger does not apply to data loaded before the definition of the trigger, therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger.
    A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.
    3 What is difference between Procedures and Functions ?
    A Function returns a value to the caller where as a Procedure does not.
    4 What is Database Trigger ?
    A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in,update to, or delete from a table.
    5 What is a Procedure ?
    A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.
    6 What is a Package ?
    A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.
    7 What are the uses of Database Trigger ?
    Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.
    8 What are the advantages of having a Package ?
    Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)
    1 With which function of summary item is the compute at options required?
    percentage of total functions.
    2 Why is it preferable to create a fewer no. of queries in the data model?
    Because for each query, report has to open a separate cursor and has to rebind, execute and fetch data.
    3 Why is a Where clause faster than a group filter or a format trigger?
    Because, in a where clause the condition is applied during data retrieval than after retrieving the data.
    4 Which parameter can be used to set read level consistency across multiple queries?
    Read only.
    5 Which of the two views should objects according to possession?
    view by structure.
    6 Which of the above methods is the faster method?
    performing the calculation in the query is faster.
    7 Where is the external query executed at the client or the server?
    At the server.
    8 Where is a procedure return in an external pl/sql library executed at the client or at the server?
    At the client.
    9 When do you use data parameter type?
    When the value of a data parameter being passed to a called product is always the name of the record group defined in the current form. Data parameters are used to pass data to produts invoked with the run_product built-in subprogram.
    10 When a form is invoked with call_form, Does oracle forms issues a save point?
    Yes
    11 What are the important difference between property clause and visual attributes?
    Named visual attributes differ only font, color & pattern attributes, property clauses can contain this and any other properties. You can change the appearance of objects at run time by changing the named visual attributes programmatically , property clause assignments cannot be changed programmatically. When an object is inheriting from both a property clause and named visual attribute, the named visual attribute settings take precedence, and any visual attribute properties in the class are ignored.
    12 What use of command line parameter cmd file?
    It is a command line argument that allows you to specify a file that contain a set of arguments for r20run.
    13 What is WHEN-Database-record trigger?
    Fires when oracle forms first marks a record as an insert or an update. The trigger fires as soon as oracle forms determines through validation that the record should be processed by the next post or commit as an insert or update. c generally occurs only when the operators modifies the first item in the record, and after the operator attempts to navigate out of the item.
    14 What is use of term?
    The term file which key is correspond to which oracle report functions.
    15 What is trigger associated with the timer?
    When-timer-expired.
    16 What is the use of transactional triggers?
    Using transactional triggers we can control or modify the default functionality of the oracle forms.
    17 What is the use of place holder column?
    A placeholder column is used to hold calculated values at a specified place rather than allowing is to appear in the actual row where it has to appear.
    18 What is the use of image_zoom built-in?
    To manipulate images in image items.
    19 What is the use of hidden column?
    A hidden column is used to when a column has to embed into boilerplate text.
    20 What is the use of break group?
    A break group is used to display one record for one group ones. While multiple related records in other group can be displayed.
    21 What is the remove on exit property?
    For a modelless window, it determines whether oracle forms hides the window automatically when the operators navigates to an item in the another window.
    22 What is the purpose of the product order option in the column property sheet?
    To specify the order of individual group evaluation in a cross products.
    23 What is the maximum no of chars the parameter can store?
    The maximum no of chars the parameter can store is only valid for char parameters, which can be upto 64K. No parameters default to 23Bytes and Date parameter default to 7Bytes.
    24 What is the main diff. bet. Reports 2.0 & Reports 2.5?
    Report 2.5 is object oriented.
    25 What is the frame & repeating frame?
    A frame is a holder for a group of fields. A repeating frame is used to display a set of records when the no. of records that are to displayed is not known before.
    26 What is the difference between OLE Server & Ole Container?
    An Ole server application creates ole Objects that are embedded or linked in ole Containers ex. Ole servers are ms_word & ms_excel. OLE containers provide a place to store, display and manipulate objects that are created by ole server applications. Ex. oracle forms is an example of an ole Container.
    27 What is the difference between object embedding & linking in Oracle forms?
    In Oracle forms, Embedded objects become part of the form module, and linked objects are references from a form module to a linked source file.
    28 What is the difference between boiler plat images and image items?
    Boiler plate Images are static images (Either vector or bit map) that you import from the file system or database to use a graphical elements in your form, such as company logos and maps. Image items are special types of interface controls that store and display either vector or bitmap images. Like other items that store values, image items can be either base table items(items that relate directly to database columns) or control items. The definition of an image item is stored as part of the form module FMB and FMX files, but no image file is actually associated with an image item until the item is populate at run time.
    29 What is the difference between $$DATE$$ & $$DBDATE$$ $$DBDATE$$ retrieves the current database date $$date$$ retrieves the current operating system date.
    30 What is the diff. when Flex mode is mode on and when it is off?
    When flex mode is on, reports automatically resizes the parent when the child is resized.
    31 What is the diff. when confine mode is on and when it is off?
    When confine mode is on, an object cannot be moved outside its parent in the layout.
    32 What is the diff. bet. setting up of parameters in reports 2.0 reports 2.5?
    LOVs can be attached to parameters in the reports 2.5 parameter form.
    33 What is the advantage of the library?
    Libraries provide a convenient means of storing client-side program units and sharing them among multiple applications. Once you create a library, you can attach it to any other form, menu, or library modules. When you can call library program units from triggers menu items commands and user named routine, you write in the modules to which you have attach the library. When a library attaches another library, program units in the first library can reference program units in the attached library. Library support dynamic loading-that is library program units are loaded into an application only when needed. This can significantly reduce the run-time memory requirements of applications.
    34 What is term?
    The term is terminal definition file that describes the terminal form which you are using r20run.
    35 What is system.coordination_operation?
    It represents the coordination causing event that occur on the master block in master-detail relation.
    36 What is synchronize?
    It is a terminal screen with the internal state of the form. It updates the screen display to reflect the information that oracle forms has in its internal representation of the screen.
    37 What is strip sources generate options?
    Removes the source code from the library file and generates a library files that contains only pcode. The resulting file can be used for final deployment, but can not be subsequently edited in the designer. ex. f45gen module=old_lib.pll userid=scott/tiger strip_source YES output_file
    38 What is relation between the window and canvas views?
    Canvas views are the back ground objects on which you place the interface items (Text items), check boxes, radio groups etc.,) and boilerplate objects (boxes, lines, images etc.,) that operators interact with us they run your form . Each canvas views displayed in a window.
    39 What is pop list?
    The pop list style list item appears initially as a single field (similar to a text item field). When the operator selects the list icon, a list of available choices appears.
    40 What is new_form built-in?
    When one form invokes another form by executing new_form oracle form exits the first form and releases its memory before loading the new form calling new form completely replace the first with the second. If there are changes pending in the first form, the operator will be prompted to save them before the new form is loaded.
    41 What is lexical reference? How can it be created?
    Lexical reference is place_holder for text that can be embedded in a sql statements. A lexical reference can be created using & before the column or parameter name.
    42 What is forms_DDL?
    Issues dynamic Sql statements at run time, including server side pl/SQl and DDL
    43 What is difference between open_form and call_form?
    when one form invokes another form by executing open_form the first form remains displayed, and operators can navigate between the forms as desired. when one form invokes another form by executing call_form, the called form is modal with respect to the calling form. That is, any windows that belong to the calling form are disabled, and operators cannot navigate to them until they first exit the called form.
    44 What is bind reference and how can it be created?
    Bind reference are used to replace the single value in sql, pl/sql statements a bind reference can be created using a (:) before a column or a parameter name.
    45 What is an user exit used for?
    A way in which to pass control (and possibly arguments ) form Oracle report to another Oracle products of 3 GL and then return control ( and ) back to Oracle reports.
    46 What is an OLE?
    Object Linking & Embedding provides you with the capability to integrate objects from many Ms-Windows applications into a single compound document creating integrated applications enables you to use the features form .
    47 What is an object group?
    An object group is a container for a group of objects; you define an object group when you want to package related objects, so that you copy or reference them in other modules.
    48 What is an anchoring object & what is its use?
    An anchoring object is a print condition object which used to explicitly or implicitly anchor other objects to itself.
    49 What is a User_exit?
    Calls the user exit named in the user_exit_string. Invokes a 3Gl program by name which has been properly linked into your current oracle forms executable.
    50 What is a timer?
    Timer is an "internal time clock" that you can programmatically create to perform an action each time the timer expires.
    51 What is a Text_io Package?
    It allows you to read and write information to a file in the file system.
    52 What is a text list?
    The text list style list item appears as a rectangular box which displays the fixed number of values. When the text list contains values that can not be displayed, a vertical scroll bar appears, allowing the operator to view and select undisplayed values.
    53 What is a property clause?
    A property clause is a named object that contains a list of properties and their settings. Once you create a property clause you can base other object on it. An object based on a property can inherit the setting of any property in the clause that makes sense for that object.
    54 What is a physical page ? & What is a logical page ?
    A physical page is a size of a page. That is output by the printer. The logical page is the size of one page of the actual report as seen in the Previewer.
    55 What is a library?
    A library is a collection of subprograms including user named procedures, functions and packages.
    56 What is a difference between pre-select and pre-query?
    Fires during the execute query and count query processing after oracle forms constructs the select statement to be issued, but before the statement is actually issued. The pre-query trigger fires just before oracle forms issues the select statement to the database after the operator as define the example records by entering the query criteria in enter query mode. Pre-query trigger fires before pre-select trigger.
    57 What is a combo box?
    A combo box style list item combines the features found in list and text item. Unlike the pop list or the text list style list items, the combo box style list item will both display fixed values and accept one operator entered value.
    58 What does the term panel refer to with regard to pages?
    A panel is the no. of physical pages needed to print one logical page.
    59 What are visual attributes?
    Visual attributes are the font, color, pattern proprieties that you set for form and menu objects that appear in your application interface.
    60 What are three panes that appear in the run time pl/sql interpreter?
    1.Source pane. 2. interpreter pane. 3. Navigator pane.
    Regards
    B RANGARAJAN

  • Triggers and Integrity rules

    Monique Vreugd : Triggers can be used for several purposes. I'm trying to write several integrity rules as triggers. The rollback here doesn't work properly? Tips are welcome!
    thxs in advance,
    CREATE TRIGGER GEBJAARTOE
    BEFORE INSERT, UPDATE ( GEB_DATUM, JAARTOE ) OF RECEIPENTS
    FOR EACH ROW
    WHEN ( YEAR (NEW.GEB_DATUM) >= NEW.JAARTOE )
    BEGIN
    ROLLBACK WORK ;
    END;

    You can't commit/rollback in dml trigger (except using autonomous transactions).
    You can however raise an exception in the trigger body, which will force to fail the statement , in which context trigger was fired and so doing a statement level rollback.
    For your example, however, you even don't need a trigger, this integrity rule can very efficiently be handled by a check constraint
    SQL> create table receipents(geb_datum date,jaartoe date,constraint check_cons check(geb_datum<jaartoe));
    Table created.Best regards
    Maxim

  • About LUW

    Hi experts,
    any body please tell me what is LUW and what is need of it inABAP pro

    Hi,
    Database Logical Unit of Work (LUW)
    From the point of view of database programming, a database LUW is an inseparable sequence of database operations that ends with a database commit. The database LUW is either fully executed by the database system or not at all. Once a database LUW has been successfully executed, the database will be in a consistent state. If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. This leaves the database in the state it was in before the transaction started.
    The database changes that occur within a database LUW are not actually written to the database until after the database commit. Until this happens, you can use a database rollback to reverse the changes. In the SAP System, database commits and rollbacks can be triggered either implicitly or using explicit commands.
    Implicit Database Commits
    A work process can only execute a single database LUW. The consequence of this is that a work process must always end a database LUW when it finishes its work for a user or an external call. Work processes trigger an implicit database commit in the following situations:
    ·        When a dialog step is completed
    Control changes from the work process back to the SAP GUI.
    ·        When a function module is called in another work process (RFC).
    Control passes to the other work process.
    ·        When the called function module (RFC) in the other work process ends.
    Control returns to the calling work process.
    ·        When a WAIT statement interrupts the work process.
    Control passes to another work process.
    ·        Error dialogs (information, warning, or error messages) in dialog steps.
    Control passes from the work process to the SAP GUI.
    Explicit Database Commits
    There are two ways to trigger an explicit database commit in your application programs:
    ·        Call the function module DB_COMMIT
    The sole task of this function module is to start a database commit.
    ·        Use the ABAP statement COMMIT WORK
    This statement starts a database commit, but also performs other tasks (refer to the keyword documentation for COMMIT WORK).
    Implicit Database Rollbacks
    The following cases lead to an implicit database rollback:
    ·        Runtime error in an application program
    This occurs whenever an application program has to terminate because of an unforeseen situation (for example, trying to divide by zero).
    ·        Termination message
    Termination messages are generated using the ABAP statement MESSAGE with the message type A or X. In certain cases (updates), they are also generated with message types I, W, and E. These messages end the current application program.
    Explicit Database Rollbacks
    You can trigger a database rollback explicitly using the ABAP statement ROLLBACK WORK. This statement starts a database rollback, but also performs other tasks (refer to the keyword documentation for ROLLBACK WORK).
    From the above, we can draw up the following list of points at which database LUWs begin and end.
    A Database LUW Begins
    ·        Each time a dialog step starts (when the dialog step is sent to the work process).
    ·        Whenever the previous database LUW ends in a database commit.
    ·        Whenever the previous database LUW ends in a database rollback.
    A Database LUW Ends
    ·        Each time a database commit occurs. This writes all of the changes to the database.
    ·        Each time a database rollback occurs. This reverses all of the changes made during the LUW.
    Database LUWs and Database Locks
    As well as the database changes made within it, a database LUW also consists of database locks. The database system uses locks to ensure that two or more users cannot change the same data simultaneously, since this could lead to inconsistent data being written to the database. A database lock can only be active for the duration of a database LUW. They are automatically released when the database LUW ends. In order to program SAP LUWs, we need a lock mechanism within the R/3 System that allows us to create locks with a longer lifetime (refer to The SAP Locking Concept).
    Reward Points if useful
    Raghunath.S
    9986076729

Maybe you are looking for

  • Using SRW api : strange error message

    Hi all, i am using the srw api to generate reports out of the database. here is the procedure i have written: CREATE OR REPLACE PROCEDURE Create_Reports AS v_paralist PORTAL.SRW_PARAMLIST; v_ident     PORTAL.SRW.JOB_IDENT; BEGIN v_paralist := PORTAL.

  • Multi-Tasking help?

    i just bought the new iphone and tried using the multitasking feature. i watched all the iphone commercials and they say that your game will be frozen when you switch to a different application. so i was playing a game and went to the multitasking ba

  • OEDQ - External Task Example

    Team, can you someone help me on External Task. I see Command, Working Directory and Arguments on External Task. Header 1 Header 2 Command java -jar jmxtools.jar runjob -job TestProject -project ABC -u dnadmin localhost:8090 Working Directory \opt\lo

  • How to add new In-app-purchases without updating app?

    I have an app already available in appstore with several number of in-app-purchase products. Now I want to add another products without updating or resubmitting my app. How to do that? Thanks.

  • SQLEception using Complex SQL Query with Java Studio Creator2 Build(060120)

    I am evaluating Java Studio Creator2 for a WEB base application project that will be making SQL queries to an Oracle Database but I have stumble into a problem using complex SQL queries. I am getting an SQLException "org.apache.jasper.JasperException