473,509 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading triggering table data in trigger (without error SQL0746N)

Hello,

I'm looking for a DB2 workaround on a topic already solved in Oracle:
the problem of mutating tables (which states that a trigger action
cannot read the triggering table's data). Yes, I know the trivial
answer: "just pass the triggering table's data as parameters to the
stored procedures called in the triggers, etc."; but it's a long story
to tell why I can't.

Below is the mentioned workaround's template I'm using for an UPDATE
trigger in Oracle (basically, it uses a package to temporarily store
affected rows for later processing):

-- SUPPORTING PACKAGE
create or replace package myTable_pkg as
type rarray is table of rowid index by binary_integer;
rids rarray;
type rMyField1 is table of number(18,2) index by binary_integer;
myField1 rMyField1;
....
....
cnt number;
end;

-- INITIALIZE COUNTER BEFORE UPDATE
create or replace trigger myTable_bu before update on myTable
begin
myTable.cnt := 0;
end;

-- POPULATE ARRAY FOR EACH UPDATED ROW
create or replace trigger myTable_aufer after update on myTable
for each row
begin
myTable.cnt := myTable.cnt + 1;
myTable.rids(myTable.cnt) := :new.rowid;
myTable.myField1(myTable.cnt) := :old.myField1;
myTable.myField2(myTable.cnt) := :old.myField2;
....
....
end;

-- DO ACTIONS FOR EACH UPDATED ROW AFTER UPDATE
create or replace trigger myTable_au after update on myTable
declare
myRow myTable%rowtype;
begin
for i in 1 .. myTable.cnt loop
select * into myRow from myTable where rowid = myTable.rids(i);
procWhichReadsMyTable(myRow.myField1, myRow.myField2, ...);
end loop;
end;
Thank you in advance...

Nov 12 '05 #1
0 1836

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3433
by: Dave C. | last post by:
Hello, I have created the following trigger: CREATE TRIGGER tr_UDFTest ON UserDefinedFields FOR INSERT, UPDATE AS DECLARE @foobar varchar(100) SELECT @foobar= foobar FROM inserted IF (...
1
7227
by: Rebecca Lovelace | last post by:
I have a trigger on a table. I am trying to dynamically log the changed fields on the table to another table, so I am iterating through the bits in COLUMNS_UPDATED() to find what's changed, and...
1
3826
by: Wavemaker | last post by:
I was wondering if there is a way to change the value of a control without triggering an event. The ComboBox control, for example, will trigger the SelectedIndexChanged event when its SelectedIndex...
8
2341
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
2
1861
by: coolnoff | last post by:
I have a dts which creates a table which is utilized on my local intranet. The DTS runs without error and the table is created/populated/transfered to the appropriate db. Then it appears that...
7
6960
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
4
2803
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
1
5437
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
5
3536
by: Ion | last post by:
Hi, I get SQL0746N when trying to call stored procedure. In my particular case I the message complains about operation "READ", but I'm posting a simplified version that results in SQL0746N with...
0
7234
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,...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.