473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trigger after the commit

I would like to know, how to get a trigger executed only after the commit is performed.
I have a table A which has a trigger tigg_A. In this trigger it would insert a record in Table B.
Now i want run a trigger Trigg_B on table B only after the commit is performed for the transaction which caused the insertion of record on Table B(ie the transaction which performed the Trigg_A)
Feb 12 '10 #1
5 21855
OraMaster
135 100+
If you want to implement such kind of functionality then don't use the triggers. You can do this by using procedure/function since the trigger gets called before/after DML regardless of commit/rollback of DML.
Feb 12 '10 #2
debasisdas
8,127 Expert 4TB
Try to use PRAGMA AUTONOMOUS TRANSACTION in the trigger at your own risk.
Feb 15 '10 #3
I guess the Pragma Autonomous and Function/procedure will not work in my scenario.Let me explain the scenario in detail.

I have 3 tables here 1. "Transaction" 2."Shipment" 3."Staging Table" and a Package "Interface"

Whenever I do a shipment "Transaction" Table will execute the trigger on it "Tran_Trigger" . In this trigger,It will insert the current Transaction details in "Staging Table".Once the records get committed, I need to call the package "Interface" which would pick up the data from "staging table" and update all transaction related tables(detail table) accordingly.
If I call the this package inside the "Tran_trigger", it will not be able to update all the trasaction detail tables as the data is not yet committed and as a result the data in detail table is out of sync.I would be able to call the "Interface" package only after the transaction is commited and all details tables are updated.
So whenever a commit is established i can immediately call the "interface" package otherwise it will cause a delay(if i schedule the package)
Feb 16 '10 #4
OraMaster
135 100+
Why do you think PRAGMA AUTONOMOUS_TRANSACTION will not work in your case. When "Tran_Trigger" gets called it will COMMIT your "STAGING TABLE". After that you can COMMIT your remaining transaction details and can call the package. If this also will not work in your case then post the code you have done so far.
Feb 17 '10 #5
What you said is true.But let explain why this wont work in my case.
The Shipment is happening in SIM(a system which i do not have access) during the shipment it triggers the "Transaction" table in RMS(where my program written) and the staging table is getting poulated.
Once the "transaction" table is updated, it will do some updation in SIM and finally get committed.Only after this point of time i can call my package (parameters are picked up from staging table data) as the entire transaction/shipment related tables are up to date.
Since i'm not sure when the transaction exactly getting completed or getting commited(as it is happening in SIM) i wont be able to call my package immediately after the process(shipment) completed. I could call the package on an intervel by using DBMS_JOBS but this will couse a delay as the job runs on a intervel and not immediately after the shipment transaction is completed.
My idea is, as soon as the transaction is completed(commited), i want to call the package so that there is no delay
Feb 18 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tom Urbanowicz | last post by:
I have a trigger. Each time the triggering event fires, I want to insert some information into another 'audit-like' table (not at all related to the trigger). Some psuedo-code is below as to what...
1
by: chandan | last post by:
hi, I have a insert trigger on a table. I want commit to happen after insert before invoking the trigger. So that if a quey is made before the completion of the trigger.Modified Data should be...
5
by: Neil Rutherford | last post by:
During testing of an application, i noticed a difference between SQL 2000 and SQL 7, both with identical config. In a nutshell: A table has a trigger for UPDATE and DELETE. When a column in the...
11
by: Peter Childs | last post by:
Is it possible to deferr a trigger until commit, Or to have the trigger not occur if the transaction is rolled back? Like transaction. I think its possible since constraints use triggers and if so...
6
by: vijai kumar via DBMonster.com | last post by:
Hi, I am using UDB v 8.1 on win2000. I have setup the ODBC datasources. My application is connecting to the database and performing DML activities. But I am getting the following error ...
6
by: JohnO | last post by:
Hi Folks, I have an update trigger that fails (it inserts an audit table record) in some circumstances. This is causing the triggering transaction to fail and roll back. Is there any way to...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
8
by: Frank van Vugt | last post by:
Hi, If during a transaction a number of deferred triggers are fired, what will be their execution order upon the commit? Will they be executed in order of firing or alfabetically or...
1
by: deepdata | last post by:
Hi, I am creating a trigger in DB2 express version. When i use the following syntax to create trigger CREATE TRIGGER USER_PK_TRIGGER BEFORE INSERT On users REFERENCING NEW As N FOR EACH...
2
by: HotFrost | last post by:
Hello everyone, i am trying to work with linked servers... The local server is the one used by UPS worldwide software (it is Microsoft SQL Server Desktop Engine, v 8.00.2050). The linked server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.