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 prevent this? If the trigger
fails I still want the triggering transaction to continue.
Cheers,
JohnO 6 9180
JohnO wrote: 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 prevent this? If the trigger fails I still want the triggering transaction to continue.
Cheers, JohnO
You can CALL a proceduer from the trigger (in DB2 V8.2). The procedure
can handle th eexception.
Now I do have a comment: You want to allow the audit to fail, but the
transaction to continue. Does that sound right? Are you 100% sure you
want that?
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Hi and thanks, Serge.
The answer to your question is no - I don't! But it's a difficult
problem. Please allow me to explain:
My trigger is a simple after update trigger used to maintain an audit
trail as shown below.
This trigger usually works just fine (in a JDEdwards OneWorld
environment which normally uses commit-immediate). However when the
triggering application is running within JDE's transaction control, the
trigger fails, with some strange (to me) looking errors. It seems that
the database is unhappy with my trigger when the triggering sql is
running within commitment control. I'm not sure how JDE does this but
from the logs below it doesn't look pretty.
Here's my trigger creation code:
create trigger TESTDTA.tr_F4102_au
after UPDATE on TESTDTA.F4102
referencing old table as oldtable
for each statement
insert into A_TESTDTA.a_F4102 select oldtable.*, user, current
timestamp, 'TESTDTA.tr_F4102_au', ow_audit.getjobname(0) from oldtable
;
And when JDE tries to do an update on the table within a commit
controlled transaction, the following is written by JDE's logging:
Aug 03 09:17:37 ** 3744/3140 UPDATE TESTDTA/F4102 SET
IBITM=1571614.000000,IBMCU='
1312',IBVEND=25748.000000,IBMRPC='1',IBUSER='JDE', IBPID='EP4114',IBJOBN='BUSERP1',IBUPMJ=105215,IBTD AY=91736.000000
WHERE ( IBITM = 1571614.000000 AND IBMCU = ' 1312' )
Aug 03 09:17:41 ** 3744/3140 SUCCESS#Journaling has already been
started for this file. Command: STRJRNPF FILE(TESTDTA/F4102 )
JRN(OWJRNL/OW_JRNL ) IMAGES(*BOTH) OMTJRNE(*OPNCLO).
3744/3140 Wed Aug 03 09:17:41 2005 JDBODBC.C2148
ODB0000183 - SQLExecute failed
3744/3140 Wed Aug 03 09:17:41 2005 JDBODBC.C2148
[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0723 - SQL trigger
TR_F4102_AU in TESTDTA failed with SQLCODE -7008 SQLSTATE 55019. -
SQLSTATE: S1000
3744/3140 Wed Aug 03 09:17:41 2005 jdb_drvm.c938
JDB9900401 - Failed to execute db request
3744/3140 Wed Aug 03 09:17:41 2005 jdb_exet.c2593
JDB3600011 - Failed to perform Update for F4102
Aug 03 09:17:41 ** 3744/3140 Entering JDB_CancelUserTransaction
Aug 03 09:17:41 ** 3744/3140 Cancelling Transaction :
1459943178_3744_3860_165816024 Commit Point Number : 1
So I guess JDE is turning on journalling for the table for the duration
of it's transaction, and setting commit points. However I don't
understand what is upsetting my trigger. It seems like my trigger needs
to inherit the triggering SQL's transaction boundaries? I have a
feeling that JDE's control method is a kludge. Hence my earlier comment
about not being so concerned about my trigger failing as long as it
doesn't upset the triggering application.
Any suggestions?
Thanks,
JohnO
Arghhhhh!
<slaps head>
The trigger is inheriting the transaction boundary of the parent
transaction, but the audit table that the trigger is inserting is not
journalled so is inconpatible with the commitment mode of the parent
transaction. I think I just need to ensure any tables modified by the
trigger are journalled!
Cheers,
JohnO
.... so the next question is: How can I start journalling on a table
within an SQL procedure? The reason I ask is that I have an SQL
procedure that I use to start auditing on any table by creating and
executing dynamic sql to create the audit table and then to create the
trigger. This procedure just needs to start journalling on the audit
table after it is created.
I know I can use a CL command to do this: STRJRNPF FILE(Lib/File)
JRN(JrnlLib/JrnlFile) IMAGES(*BOTH) OMTJRNE(*OPNCLO). How can I invoke
this from within an SQL procedure? Or do I need to write a CL stored
procedure to do this?
Cheers,
JohnO
JohnO wrote: Hi and thanks, Serge.
The answer to your question is no - I don't! But it's a difficult problem. Please allow me to explain:
My trigger is a simple after update trigger used to maintain an audit trail as shown below.
This trigger usually works just fine (in a JDEdwards OneWorld environment which normally uses commit-immediate). However when the triggering application is running within JDE's transaction control, the trigger fails, with some strange (to me) looking errors. It seems that the database is unhappy with my trigger when the triggering sql is running within commitment control. I'm not sure how JDE does this but from the logs below it doesn't look pretty.
Here's my trigger creation code:
create trigger TESTDTA.tr_F4102_au after UPDATE on TESTDTA.F4102 referencing old table as oldtable for each statement insert into A_TESTDTA.a_F4102 select oldtable.*, user, current timestamp, 'TESTDTA.tr_F4102_au', ow_audit.getjobname(0) from oldtable ;
And when JDE tries to do an update on the table within a commit controlled transaction, the following is written by JDE's logging:
Aug 03 09:17:37 ** 3744/3140 UPDATE TESTDTA/F4102 SET IBITM=1571614.000000,IBMCU=' 1312',IBVEND=25748.000000,IBMRPC='1',IBUSER='JDE', IBPID='EP4114',IBJOBN='BUSERP1',IBUPMJ=105215,IBTD AY=91736.000000 WHERE ( IBITM = 1571614.000000 AND IBMCU = ' 1312' ) Aug 03 09:17:41 ** 3744/3140 SUCCESS#Journaling has already been started for this file. Command: STRJRNPF FILE(TESTDTA/F4102 ) JRN(OWJRNL/OW_JRNL ) IMAGES(*BOTH) OMTJRNE(*OPNCLO). 3744/3140 Wed Aug 03 09:17:41 2005 JDBODBC.C2148 ODB0000183 - SQLExecute failed
3744/3140 Wed Aug 03 09:17:41 2005 JDBODBC.C2148 [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0723 - SQL trigger TR_F4102_AU in TESTDTA failed with SQLCODE -7008 SQLSTATE 55019. - SQLSTATE: S1000
3744/3140 Wed Aug 03 09:17:41 2005 jdb_drvm.c938 JDB9900401 - Failed to execute db request
3744/3140 Wed Aug 03 09:17:41 2005 jdb_exet.c2593 JDB3600011 - Failed to perform Update for F4102
Aug 03 09:17:41 ** 3744/3140 Entering JDB_CancelUserTransaction Aug 03 09:17:41 ** 3744/3140 Cancelling Transaction : 1459943178_3744_3860_165816024 Commit Point Number : 1
So I guess JDE is turning on journalling for the table for the duration of it's transaction, and setting commit points. However I don't understand what is upsetting my trigger. It seems like my trigger needs to inherit the triggering SQL's transaction boundaries? I have a feeling that JDE's control method is a kludge. Hence my earlier comment about not being so concerned about my trigger failing as long as it doesn't upset the triggering application.
Any suggestions?
Hmm, SQLSTATE 55019 means: "table in an invalid state for the
operation". In DB2 for LUW this would imply check pending
I'm neither an expert on iSeries nor JDEdwards, I'm affraid.
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Thanks Serge - That was the clue - I cracked the problem as detailed in
my followups. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joel Thornton |
last post by:
Whenever something is inserted to a given table, I want to run some
shell commands using xp_cmdshell. Would it be a bad idea to put this
xp_cmdshell in the INSERT trigger of this table?
I...
|
by: Scott CM |
last post by:
I have a multi-part question regarding trigger performance. First of
all, is there performance gain from issuing the following within a
trigger:
SELECT PrimaryKeyColumn FROM INSERTED
opposed...
|
by: Elvira Zeinalova |
last post by:
Hei,
We have 2 MS SQL SERVER 2000 installed on 2 different servers (2 separated
machines).
I am triing to connect them så that when one row is added to the table in
the database in main server - ...
|
by: dhornyak |
last post by:
I have been banging my head against the wall for a while now, and can't
seem to id the problem. I've been through a ton of posts and the code
doesn't seem any different. Can anybody see it?
When...
|
by: Rajat Katyal |
last post by:
----- Original Message -----
From: Rajat Katyal
To: pgsql-jdbc@postgresql.org
Sent: Saturday, January 31, 2004 10:15 AM
Subject: Trigger function aborts the transaction on exception
Hi:...
|
by: Rajat Katyal |
last post by:
Hi:
I came to know from the postgresql documentation that PostgreSQL does not have a very smart exception handling model. I wonder whether anyone can helpme or suggest some alternate solution for...
|
by: Marty Cruise |
last post by:
I successfully deploy my application to 20 domain users. Only one new user
is giving me a problem, although he can access all domain resources.
When he clicks the installation link on the...
|
by: yinzara |
last post by:
I have the following trigger that calls a DB2 stored procedure:
DROP TRIGGER GGWU.TRI_A_MULTI_PROP@
CREATE TRIGGER GGWU.TRI_A_MULTI_PROP AFTER INSERT ON
GGWU.MULTIPLIER_PROPERTY REFERENCING ...
|
by: bwestover |
last post by:
I am trying to pull data out of an application database and transform it to another medium.
I have direct access to the database, but I cannot alter the program code.
What I want to have happen...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |