473,698 Members | 2,203 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(my Table.cnt) := :new.rowid;
myTable.myField 1(myTable.cnt) := :old.myField1;
myTable.myField 2(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) ;
procWhichReadsM yTable(myRow.my Field1, myRow.myField2, ...);
end loop;
end;
Thank you in advance...

Nov 12 '05 #1
0 1849

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

Similar topics

6
3443
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 ( @foobar = 'foobar') INSERT INTO LogTable (LogText) values ('Found foobar')
1
7231
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 getting the column name programatically. This is all working fine. If I do a regular insert command in my trigger then everything works fine. However, since I want to retrieve data from the column name which I got programatically from the...
1
3899
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 property is changed. I would like to change the SelectedIndex property without triggering an event. The reason I ask is that in the application I'm writing, I have many controls that manipulate the program data. The data is encapsulated into...
8
2351
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 event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField from lstDepartments. It's quite apparent though that the event is not triggering as I can misname...
2
1882
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 there is an action on this table which truncates it. I have been unable to determine the culprit. Can I create a trigger that will capture truncation? I have tried to create a trigger to capture this information but none that I attempt seem to...
7
6982
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 into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
4
2818
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" src="country_state.js"> </script>
1
5450
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 group get automatically re-directed after uploading. However, this member group never gets the benefit of knowing if they've uploaded an incorrect file size or incorrect file extension. Members from the second group do see the "exceeds max file...
5
3575
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 "MODIFY". I assume there is a similar reason, but I'm not quite sure what I'm doing wrong here. Any idea? I'm running 9.5 SP 0 on windows. Thank you! create table t(Id int not null primary key generated by default as
0
8672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7712
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4361
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.