Database Triggers - Autonomous Transaction Issue

Hi ,
I have a EMP table.
I wrote a AFTER ROWLEVEL Database Trigger for EMP table.
While Updating value in EMP table , my trigger is firing.
Issue:
My requirement is , I want to find the Count(1) in EMP table for the updated record.It is not including the updated record in my count.
If i execute the count(1) , outside the session , it is giving the correct value.But inside trigger i am not getting the exact count.
Can u pls help me.
Sample Coding:
While updating DEPT_CODE , the following trigger is firing.
CREATE OR REPLACE TRIGGER testing
AFTER UPDATE OF DEPT_CODE
ON EMP
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
t_count number;
cursor c_emp
is
select count(1)
from emp
where dept_code = :NEW.DEPT_CODE;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
open c_emp;
fetch c_emp into t_count;
close c_emp;
dbms_output.put_line('t_count '||t_count);
END;
I got count as 5.
But if i execute the count in SQL , it is giving count as 4.
In the database trigger , it is not taking the record which was updated .

why a trigger (... not even going to ask why an autonomous trigger... )
SQL> drop table t
  2  /
Table dropped.
SQL>
SQL> create table t
  2  as
  3  select rownum id
  4    from all_objects
  5   where rownum <= 10
  6  /
Table created.
SQL>
SQL>
SQL> var cnt_upd number
SQL>
SQL> update t
  2     set id = id + 1
  3   where id > 5  
  4    returning count(id) into :cnt_upd
  5  /
5 rows updated.
SQL>
SQL> print
   CNT_UPD
         5
SQL>

Similar Messages

  • Exam 1z0-147 - Autonomous transactions in triggers

    hi all,
    I am taking my 1z0-147 exam soon and I would like to know if anyone can help me out with this dilema.
    all the practice material I have used states that transactional statements such as COMMIT cannot be performed inside a trigger. However this is not completely true as you can perform commits and other ddl etc inside a trigger if you declare it as an autonomous transaction...
    I would like to know if anyone can reccommend which approach I should take for answering the real exam questions. which answer is right? Can I perform a commit inside a trigger or not?
    Thanks in advance!
    Steve

    user11694872 wrote:
    hi all,
    I am taking my 1z0-147 exam soon and I would like to know if anyone can help me out with this dilema.
    all the practice material I have used states XXXXXXXXXXXXXXXX. However this is not completely true as YYYYYYYYYYYYYYYY..
    I would like to know if anyone can reccommend which approach I should take for answering the real exam questions. which answer is right? Can ZZZZZZZZZZZZZZZZZZZ or not?
    Thanks in advance!
    SteveIts probably bad practice to ask questions on certification related questions here, and your question might fail a strict interpretation of the Non-disclosure agreement.
    You should probably try to get a response from the source of your legitimately obtained authorized practice questions:
    [http://blogs.oracle.com/certification/2009/05/the_route_you_choose.html]
    [www.certguard.com]
    This also means I best not comment directly on this, especially as I have taken 1z0-147
    And Its why I've censored my quoting of your response
    The key thing is to remember that the answer required is best answer from information gained in the question (and an excepton not on syllabus in unlikely to contribute to best answer ... but thats a judgement call).
    If you really feel an ambiguity during the exam I think a comment button is present and you may care to use it ... but of course this loses time ... and probably will you you more than you gain. You could then possilby argue a borderline fail, but if your borderline anyway then probably the best to reasonably hope for would be a free retake, so barely worth the candle.
    I think most exams try to weed out ambiguous questions, however I recall not being best happy with certain answers I saw from an authorized source material I used for this exam. In fact I think 1z0-147 is a rehash on 1z0-101. In fact I take a right scunner to 1z0-147 and am pleased to see the arrival of 1z0-144 .... Though I half wonder if there's been more interest in 1z0-147 since 1z0-144 arrived :-;
    Rgds- bigdeboy

  • Autonomous transaction performance

    Hi,
    My trigger issues a ddl, so I had to do it in an autonomous transaction to avoid the problems with commits in triggers. Is there any performace consideration doing so? Does the DDL command execute slower in a trigger in an autonomous transaction as in a normal one issued by the appliaction?
    Thank you very much in advance!
    torell

    Oracle has been using autonomous transactions under the covers for years, so I would assume that there won't be a noticable performance penalty, if there is in fact a penalty. I'd bet dollars to doughnuts that the performance is identical.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Performing DDLs in themiddle of a transaction: use Autonomous Transactions?

    We want to use Oracle Spatial to store some of our data, for example SDO_PC, a Spatial type for arbitrarily large point clouds. The problem is that the standard way to populate a SDO_PC instance (in a row) is via SDO_PC_PKG.CREATE_PC, which turns out to be a DDL operation, and furthermore operates on an input table containing just the points to inserts for that SDO_PC instance, thus one needs to create a temp table as well per point cloud (or reuse the same, serializing access to it), another DDL.
    But when the user hit save in our application, she may have 10 or 20 or 100 point clouds to save, and I'd want the entire save to be in a single large transaction (I asked about it in this forum a while back, and was answered to make my transactions as large as they should "logically" be, which is a "save" operation in this case).
    How does one resolve doing the save in a single transaction, when the save itself requires calling SDO_PC_PKG.CREATE_PC (which is a DDL) multiple times?
    Are "Autonomous Transactions" the solution? (I've read in Ask Tom that Autonomous Transactions are miss-used most of the time; would it be true here as well?)
    Must the application open a separate Connection to the same server, and perform the DDLs in this other connection? If so, will the first "transactional save" connection be able to access the side effects (tables, etc...) of the DDLs of the "DDL" connection?
    What other solution to this issue could be implemented?
    In a related issue, in this Spatial thread Performance of insert with spatial index someone proposed dropping a Spatial Index before an insert to recreate it afterward, to overcome a large overhead on the insert, but this also implies DDLs in the middle of a large multi-table transaction, so would a solution to the SDO_PC_PKG.CREATE_PC issue above apply equally well in this case as well?
    As everyone can tell, I'm fairly new to databases and Oracle, so I'd appreciate the help of more experienced DBAs / Application Database Architects on this. Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Thanks Justin. I didn't think of this, even though I've looked at Workspace Manager a bit, and it's something we are considering using in the future.
    But I'm worried about 1) the complexity that Workspace Manager adds, where every table is renamed and replaced by a view, and 2) the performance implications of all the instead of triggers to write to the underlying data tables.
    Furthermore, I wonder how Workspace Manager would scale with hundreds of users, since having the save done in a separate branch kinda implies having a branch per user, and thus hundred of branches. Plus Workspace Manager uses VPD I think, yet another complication (again, we'll probably have to bite the bullet eventually, but I'd rather that be later than sooner).
    Thus I'm reluctant to go the Workspace Manager route at this point, because we already have so much going on with Oracle that I'd rather leave this layer out, at least for now.
    What about the parallel connection or autonomous transaction options? Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • AUTONOMOUS TRANSACTION(8I NEW FEATURE)에 대한 소개

    제품 : ORACLE SERVER
    작성날짜 : 2003-10-14
    AUTONOMOUS TRANSACTION(8I NEW FEATURE)에 대한 소개
    ==================================================
    autonomous transaction은 child transaction이라고도 불리우며 Oracle
    8i부터 제공되는 새로운 기능이며 현재까지는 pl/sql을 통해서만 구현이
    가능하지만 앞으로는 OCI까지 확장될 예정이다.
    pl/sql routine의 declare section 중 어떠한 곳에서라도 아래의 progma
    (compiler directive)를 지시함으로써 autonomous로 구분이 가능하다.
    pragma AUTONOMOUS_TRANSACTION;
    'pragma'는
    1) top-level anonymous blocks
    2) local, standalone or packaged functions and procedures
    3) methods of object types
    4) database triggers의 declare section 어디에서나 나타낼 수 있슴.
    아래의 경우에는 사용이 불가능.
    1) outside of a declase section
    2) nested block의 declare section
    3) package specification
    4) package body 중 procedure나 function definition 외부
    5) type body중 method definition의 외부
    autonomous transaction(tx) 내에서 명시적으로 rollback이나 commit을
    하여야 한다. 만일 이를 위반하였을 경우 main transcation 및 child
    transaction 모두 error 발생과 함께 rollback이 되게 된다.
    main transaction이 수행 중이고 child transaction이 아래의 상태의 경우 :
    1) autonomous transcation으로 선언된 code unit의 declare section에서
    기술된 statement가 수행 중인 동안 parent tx는 active로 남아있게 된다.
    2) "begin" 이후의 첫 executable step을 만나게 되면 parent transaction은
    유보되고 새로운 tx(child tx)가 시작된다.
    3) 이 code unit은 normal하게 수행이 되나 tx context는 새로운 transaction로
    설정된다.
    4) autonomous code unit에서 commit 이나 rollback 이 수행되면 이
    autonomous tx은 종료된다. 이 때까지 parent(main) tx는 계속 유보상태로
    남아 있으며 autonomous unit에서 계속되는 operation이 있다면 새로운 tx이
    시작된다.
    5) autonomous code unit에서 exit를 하게 되면 transaction context는
    parent로 전환이 된다.
    transaction context의 변경은 session parameter에 영향을 주지 않는다.
    따라서 parent transaction 에서 적용된 session parameter는 그대로 child
    tx에서도 영향을 미치게 된다.
    parent tx와 child tx는 서로 독립적이므로 lock 역시 공유하지 못한다.
    만일 parent tx에서 점유된 lock을 child에서 소유하고자 한다면 dead lock
    현상이 발생할 것이다. 이런 경우 ORA-60 이 발생되고 child tx는 자동적으로
    rollback 된다.
    <주의>
    ORACLE 8.1.6 README에서는 분산 transaction에서 autonomous tx 사용 시
    dead lock 발생 시 distributed lock timeout을 정상적으로 하지 못한다는
    주의사항이 소개되고 있슴.
    [예제]
    create table test_lobs (c1 number,c2 clob);
    create table msg (msg varchar2(120));
    create or replace function getlen (p1 in clob,
    p2 in number) return number as
    pragma AUTONOMOUS_TRANSACTION;
    len number;
    buf varchar2(120);
    tlen number;
    begin
    len := dbms_lob.getlength(p1);
    if len != 0 then
    dbms_lob.read(p1,len,1,buf);
    dbms_output.put_line('Value: '||buf);
    insert into msg values (buf);
    commit;
    end if;
    select dbms_lob.getlength(c2) into tlen
    from test_lobs where c1=p2;
    dbms_output.put_line('Length selected from table is '||tlen);
    return len;
    end;
    insert into test_lobs values (1,'Hello');
    insert into test_lobs values (2,'The quick brown fox');
    commit;
    declare
    cl1 clob;
    cl2 clob;
    ret number;
    begin
    select c2 into cl1 from test_lobs where c1 = 1 for update;
    select c2 into cl2 from test_lobs where c1 = 2;
    ret := getlen(cl1,1);
    dbms_output.put_line('Length of first row is '||ret);
    ret := getlen(cl2,2);
    dbms_output.put_line('Length of second row is '||ret);
    dbms_lob.writeappend(cl1,6,' there');
    ret := getlen(cl1,1);
    dbms_output.put_line('Length of first row is now '||ret);
    end;
    gives:
    Value: Hello
    Length selected from table is 5
    Length of first row is 5
    Value: The quick brown fox
    Length selected from table is 19
    Length of second row is 19
    Value: Hello there
    Length selected from table is 5
    Length of first row is now 11
    Selecting from the msg table gives 3 rows as follows:
    Hello
    The quick brown fox
    Hello there

  • Ora 02290 when using qms_transaction_mgt and autonomous transactions

    Hi all,
    I'm using the qms procedures:
    qms_transaction_mgt for openeing and closing transactions.
    Somewhere in my procedure when the transaction is opened i call another procedure which contains a autonomous transaction.
    The next time qms_transaction_mgt.close_transaction is called i get an ORA-02290: check constraint (HST65.QMS_NEED_TO_CLOSE_TRANSACTION) violated
    When i debug the qms_transaction_mgt.close transaction the g_current_trans_id variable is empty, which indicates the transaction is allready closed.
    When i remove the pragma autonomous_transaction statement and the commit statement from the procedure i call, the problem is resolved.
    Version information:
    Designer 9.0.2 with a with a Oracle 9i 9.2 database and Headstart 9i.
    Does anybody know how i can resolve this or if this is a bug and how to fix it?
    Thanks,
    Yvon

    Ian, Yvon,
    It is unfortunately a know restriction that the CDM RuleFrame component of both Headstart for Designer 6i and Headstart for Designer 9i doesn't work in combination with autonomous transactions.
    The reason is that the RuleFrame administration relies on information stored in 1. pl/sql package variables and 2. database tables. Using autonomous transactions (that involve CDM RuleFramed DML) causes this information to dissynchronize.
    A year ago I investigated the possibilities to make autonomous transactions possible with RuleFrame but unfortunately this is fundamental problem: RuleFrame wants to combine multiple DML-actions into one logical transaction (gards this with the "need_to_close_transaction" constraint), while autonomous transactions intend to to the opposite: commit a part of a transaction while the rest of the transaction still is posted/not committed.
    There is one exception: if you call an atonomous procedure that does DML on a non-ruleframe-enabled table (no TAPI triggers that intend to open/close the transaction, no CAPI etc), everything functions.
    Problem explanation:
    ====================
    1. Outer transaction is opened (by front end or TAPI triggers of first DML)
    2. DML takes place
    3. Autonomous transaction-procedure is called
    4. Auto-transaction again tries (and succeeds!) to open the transaction, it doesn't see that the transaction is opened (db table qms_transactions is empty for the autonomous transaction on query)
    5. DML within auto-transaction is posted
    6. Auto-transaction closes transaction
    7. Auto-transaction is committed
    8. Outer transaction thinks the transaction is already closed, because the auto-transaction cleaned out the package variables when it closed the transaction.
    9. Commit of the outer transaction fails as the deferred check constraint need_to_close_transaction avoids this to happen (rollback takes place because of this violation).
    Hope this helps
    Kind Regards
    Marc Vahsen
    Headstart Team Oracle NL

  • Workflow and autonomous transactions

    I am trying to implement Workflow to execute PL/SQL procedures that are currently executed manually on my project. Most of the procedures issue commits or rollbacks and per Oracle support I needed to use PRAGMA AUTONOMOUS_TRANSACTION in the Workflow "wrapper" procedures to prevent errors with workflow. This has been successful with the vast majority of our procedures, however, in at least one case, a procedure that we execute (inserting millions of rows, Gbs of data) never finishes.
    At first I thought that workflow might be the problem, but I have tested the procedure outside of Workflow in SQLPLus with the PRAGMA declared with the same result.
    If I execute the procedure without the PRAGMA from SQL Plus without workflow it finishes in just under 4 hours (the expected time frame). Any ideas about what might be the cause of this strange behavior?
    The problem seems to be caused by the PRAGMA which I need to implement Workflow. Any help would be much appreciated.

    This sounds like a database issue rather than a workflow issue. If it does not work from PL/SQL outside of workflow, then I would suggest logging a TAR with Oracle Support. Sounds like you have narrowed it down to an autonomous transaction that runs for > 4hours.
    You might want to include a simple reproducible test case as well in the TAR. In the mean time, you could try and break down the amount of work being done into a number of PL/SQL calls instead of one. For example 4 * 1hour PL/SQL calls instead of 1 that lasts 4 hours and doesnt work.
    HTH
    Mark

  • Is commit necessary to end autonomous transaction?

    CREATE OR REPLACE TRIGGER TRIG_EMP
    AFTER UPDATE
    ON EMP
    FOR EACH ROW
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    CNT NUMBER := 0 ;
    BEGIN
    --PROCE_TRIG_TEST_EMP;
    SELECT COUNT(*)
    INTO CNT
    FROM EMP;
    UPDATE EMP_bkp
    SET COMM=999
    WHERE ENAME ='SMITH';
    -- COMMIT;
    DBMS_OUTPUT.put_line('TRIG_EMP CALLED.. DONE: '||CNT);
    END;
    Error: "autonomous transaction detected "
    if i open update n block commit code then error.
    if i block both update n commit code then without commit code is running fine.
    My Ques: If commit is necessary to end autonomous transaction then when i m blocking update n commit lines then too running without above error?
    plz clear my concept..
    pc

    PC wrote:
    thanks ..I will take care of it i.e. "IM".
    In above code when I am blocking both "update & commit code lines" then there is no error raised by program.
    I am using commit when I need that my "update transaction must be commit",if I am only taking "count of table emp" then no need of commit...
    Like this I am not getting any exception..!Doing anything on the same table that caused the trigger to fire can lead to you getting a mutating table error, so care should be taken in that respect.
    I got your point that I must commit and I will use it but here if I am using autonomous transaction without commit then I must get error but I am not facing ..plz guide me againThe point of an autonomous transaction is to effectively make Oracle spawn off a seperate transaction. Usually we consider that we have just a single transaction per session at any one time, but there are times, like when we need to log errors or audit something, that we want to ensure something get's written to a table, even if the transaction we are in needs to be rolled back or is about to raise an exception. In such cases we use an autonomous transaction to spawn the seperate transaction to perform that task. Good design would have that autonmous transaction as a seperate procedure to be called (rather than in the trigger itself) to keep it completely seperate from the current transaction, and thus when that seperate procedure finishes, any changes it has made must be committed or rolled back because the autonomous transaction that has been spawned is about to finish. Of course, if that procedure doesn't actually do any work on the database that requires committing or rolling back, then it's not necessary to issue one, but then there would be no need for an autonomous transaction in the first place.
    So, with your trigger (let's ignore that fact that making the trigger autonomous is p!ss poor design), if you only do the count and don't do the update statement, then there is nothing to be committed, so there's no need for a commit statement, even if the trigger is defined as an autonomous transaction. But, if you include the update statement, then that spawned transaction must be committed before the trigger ends, so that the transaction is completed and control can return to the calling transaction. So, making your trigger autonomous doesn't mean that it must commit by itself... but making it autonomous and including something that needs committing, does mean it must commit.

  • Autonomous transactions not seeing posted data

    I want to add a button to a form to call a report. The users want to update data in the form, run the report then decide if the data is to be committed. I can post the changed data but the report doesn't see the posted data as Oracle starts a new session.
    The report performs various calculations and before it is run, the calculations are performed and data extracted to separate tables, the report then runs on the extracted data then the temporary table data is deleted.
    I thought autonomous transactions would be my solution. The data is posted within forms, the form then calls a database procedure which has the autonomous procedure declared, data extracted and committed to the temporary tables within the autonomous transaction (form data stays uncommitted), report runs using the extracted data. User could then decide if the amended data could then be committed to the database.
    The autonomous transaction does not seem to see the posted data. The procedure picks up the data 'pre post'. Any ideas on what I can do to get round this?
    Thanks in advance
    Karen Stalker

    Thanks for all the replies.
    My form that will call the report can call up to 12 other forms with data always posted and never committed until the user is prompted to on leaving the main form, or the user presses the commit key. I liked the idea of writing to a temporary table but the way this application is designed, this would mean a big rewrite of a lot of complicated forms. I would rather leave them alone as they work!!
    I could pass the record groups into the report - this would mean about 15 groups but that shouldn't be a problem except that there are a few child queries which I read can't be done that way. This may be a daft question but can I pass the record groups into the report and the record groups be then used in the after parameter trigger. There I could do all the necessary complications, write to my extract tables and then carry on as normal - i.e. the report gets the data from these extract tables.
    My best solution would be to get the reports and forms to run in the same session but how can I do this? As far as I'm aware, RUN_REPORT_OBJECT starts a new session. Hopefully someone knows how to get them in the same session.
    Thanks again
    Karen

  • How to create database triggers in ABAP Dictionary

    Hi,
    How can i create database triggers on tables, like the update, delete and insert triggers which we used to create in SQL sever and other databases, is there any transaction for doing the same from ABAP dictionary. or should it be done at the raw database level.
    Thanks
    Akila.R

    Hi,
    please check out the following link it might help you
    http://help.sap.com/saphelp_nw2004s/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm
    *************please reward points if the information is helpful to you******************

  • ORA-00164: autonomous transaction disallowed within distributed transaction

    I have been trying to solve this problem for weeks now, I have posted this question everywhere I can think of, but I havent really received and answer that has helped, so now I am going to post it here hoping for an answer.
    We are running 9iAS on Solaris and when the following stuff is run we are getting ORA-00164 errors. If you refresh the page a bunch of time the problem goes away. But it comes back the next time you try to execute the procedure again. Here are the cases when the problem shows up.
    Editing the style:
    PROCEDURE : PORTAL30.wwpob_app_style.edit_style
    Saving changes to the banner for a page
    PROCEDURE : PORTAL30.wwptl_banner.savecustom
    Logging out
    PROCEDURE : PORTAL30.wwsec_app_priv.logout
    After setting the default user group and applying the changes:
    PROCEDURE : PORTAL30.wwsec_app_user_mgr.edit_user
    Creating a new group:
    PROCEDURE : PORTAL30.wwsec_app_group_mgr.create_group
    Opening the add portlet screen:
    PROCEDURE : PORTAL30.wwv_main.main
    There are a few other places but I don't have them documented. In ALL cases the problem goes away once we start and stop the Apache using the following comands:
    /app/oracle/n_portal/Apache/Apache/bin/apachectl stop
    ps -ef | grep httpd | grep n_portal
    /app/oracle/n_portal/Apache/Apache/bin/apachectl start
    After starting and stopping Apache the problem is gone for a little while (20-30 mins) then it starts coming back slowly (sometimes the problem is there then it is not). Once the problem is back if you continually press refresh on the browser (5-10 times) the page might appear, if the page does not appear you will see the
    ORA-00164: autonomous transaction disallowed within distributed transaction
    The following error appears in apache log (50% of the time) when Autonomous Transaction error shows up on the screen:-
    DSHttpSessionBindingListenerImpl.valueUnbound : closing DS session : DSSession id = 5225534324468880950975536484
    215 PortalSession id = 521335001720MERAJ
    DSHttpSessionBindingListenerImpl.valueUnbound : closing DS session : DSSession id = -638034231325135430097553725
    8001 PortalSession id = 992335001711JDALGLIESH
    These errors might be related to dynamic services but we were had the problem long before Dynamic services was installed.
    We want to start pre-production user testing as we have just had 11 developers building portlets for the company, but we cant do much with this error popping up every time a user wants to test it. We have one of the Oracle consultants here and he has asked the oracle developer group what the problem could be, and they seem to think it might be related to our use of DB links however, we never get the problem when we try to run a portlet that uses a database link.
    Please help.
    Jeff Dalgliesh
    null

    Jay,
    My name is Craig McCauley. I'm an Oracle Technical Manager working onsite at Unocal Indonesia. I'm with the Portal group in ATS.
    When I got here the first thing we did was bump up init.ora parameters and apache confif parameters as suggested by the iPlatform group. We have thes sessions parameter (in init.ora) bumped up from 100 to 700. I'm watching v$session and the get these AT messages with as few as 70 total db sessions. Any help your group can give will be greatly appreciated.
    Unocal is planning on implementing Oracle Portal globally - as a common interface. They have similar installs in Thailand and Houston and thus far have not seen the AT messages (although there has not been much development going on at those sites).
    Thanks,
    Craig

  • Autonomous transaction in trigger

    Hi,
    Can we use commit within a database trigger? I think yes if we use autonomous transaction in that trigger.
    Please confirm and if it is correct please provide an example of this.
    Thanks,
    Mrinmoy

    user3001930 wrote:
    Can we use commit within a database trigger? I think yes if we use autonomous transaction in that trigger.
    Please confirm and if it is correct please provide an example of this.Yes, you can commit in an autonomous transaction within a trigger, but bear in mind that that is only committing the transcation that is autonomous, not the original sessions changes. So if you're expecting to be able to commit the data in your present transaction that has caused the trigger you are mistaken.
    Perhaps the simplest way to look at an autonomous transaction is as though the database has started up a seperate session to execute some transactions, and before execution can return to the original session it must commit or rollback what it's done in that second session, however that second session cannot influence the transactions taking place in the first session.

  • Replacing / Compiling Database Triggers in a HA/High Load system

    Hi there,
    My collegue has just asked me if downtime needs to be scheduled to replace an After IUD Database trigger where I've made a minor change.
    If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.
    What about when working with database triggers?
    If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?
    Notes:
    Oracle 10g R2 db.
    High DML rates on the table that the After IUD Trigger is 'attached' to.
    It's a near certainty that when the Create or Replace Trigger DDL runs, the trigger will be active at the time.
    The Trigger is 'simple' in that it's use: is to call a DB package with some of the :new values as params.
    +(I'm happy to rtfm - if someone can tell me where!!)+
    Cheers -
    Ron Marks

    If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.Not true. This exception is thrown only if sessions have some state represented in package variables. If there is no associated session state, then no exception would be thrown after recompile.
    If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?You'll wait - to lock an object in library cache which represents your trigger. Not sure if this would require a library cache lock on underlying table, but I would guess that it is required. BTW, locking a table would make no any sense: CREATE TRIGGER is a DDL, which means before it began it issues a COMMIT => all locks are released, and it is quite possible that a TM lock for CREATE TRIGGER won't be acquired since resource would be busy.
    Oracle 11gR2 claims to address problems of application upgrades on a high-load environments with a feature called "Editions" (not a good name - try to find something about it via Google...)

  • Using Autonomous Transaction in dbms_job on Oracle 8.1.6

    I am submitting a package.procedure job to run using dbms_job.run procedure on Oracle 8.1.6 database.
    The package.procedure calls another autonomous transaction procedure to handle the exceptions.
    The dbms_job.run works fine if no exception is encountered, however if
    there were to be an exception, resulting in a call to auto. trans.,
    I encounter -
    SQL> exec dbms_job.run(152404);
    ERROR:
    ORA-01041: internal error. hostdef extension doesn't exist
    begin dbms_job.run(152404); end;
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    If I submit this thru an Oracle Form, the form also throws me out for this unhandled exception.
    When I comment out the auto. trans. procedure in exception handling section, dbms_job.run works fine.
    Also when I directly execute the package.procedure without submitting thru dbms_job, the auto. trans. is able to handle the exception.
    Does it mean auto. trans. is not compatible with dbms_job in Oracle 816 or there is any patch out there ?
    Any clues will be highly appreciated.
    thanx

    There is a rollback before the auto. trans. guy gets called.
    The auto. pragma itself gets committed too and is also rollbacked in event of a failure.
    The transaction works fine in all situations when not submittted thru dbms_job.run
    null

  • Autonomous transaction - user updating information through form

    Good afternoon,
    I have a form that has a database datablock that is populated using a cursor that does a select on 4 tables, being one the most important (table A). When the user is done he commits the changes and the information is saved in table B, the "source" of the datablock.
    This generates a concurrency problem: if two users give the same parameters the cursor populates the same information in their respective sessions and the information is saved twice. I want to prevent this, only one person should be allowed to use the information.
    I know about autonomous transactions and perhaps this is the best idea: update the status of the row in table A in order to prevent any further uses but i want to check any other solution. Perhaps i could write the user and the time and the second person would get a message: "being used by"
    Thanks,

    Yes i too have read about autonomous transaction and its very rare usability.
    Ok here's the situation:
    Table B
    code_B (number) PK
    code_B1 (number PK
    description
    selected (Y/N), default N
    more fields...
    Table A
    code_A PK
    description
    code_B NOT part of PK_A
    code_B1 NOT part of PK_A
    more fields
    step 1: user opens form X and marks some records from table B, setting selected to Y
    step 2: User open forms Y and populates block Z (table A) based on a cursor (PL/sql run through a push button) that looks for all the records from B that have selected = Y
    step 3: user commits and the form updates table A with new records
    this is the normal procedure but sometimes two users open form Y at almost the same time and the both populate the datablock Z with the same info.
    I have thought about creating a new hidden datablock in form Y that uses table B, in order to block other users.
    and these forms have been like this for years now, i did not create them and the tables have millions of records now...
    This was a design flaw, not taking concurrency into account i guess
    Many thanks
    Edited by: user474437 on Apr 17, 2010 10:38 AM

Maybe you are looking for

  • Error 554-5.6.0 Corrupt message content... when sending emails to other users on same exchange server

    Hello I have a very strange problem at a customer from our company. The problem happens to only one user on the Exchange 2010 organization (SP3, no additional patches installed, Server is 2008 r2). When this specific user sends an email to one or mor

  • XLLT mapping program

    Hi, I have to send an Idoc from SAP to a 3rd party using webservices. The request message( for web service) has 5 inputs.Idoc has to as a first input rest of the inputs are hard coded values.     Now I want the Idoc in the form of a string on the tar

  • Consume Type Any in abap proxy

    Hi experts, Is it possible to consume the type Any in abap proxy?. I dont want to change the schema type to string. The generated proxy hasn't any final type. Check the screenshoots: Regards.

  • Can Enterprise users have more than 1 Shared Schema ?

    Hi Everyone, I just want to know whether is it possible for Enterprise Users ( Schema-Independant users) able to access different shared schemas using the same user credentials. A typical example is : User1, User2 & User3 were Enterprise users who wo

  • New Message Above Navigator / Why is it showing up?

    Hi, I have a something new happening when using LR3.3. Not sure if always occured but was hidden or not. The situation is...... When I have a RAW image opened that I have chosen from my library., If I do an action (example crop, exposure correction,