473,394 Members | 1,759 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,394 software developers and data experts.

Trigger Db2 V8.xx

Hi to all Ng

Sorry for my bad english.

I have got a problem. I understand if a user try to update more than 10 row in a table.

So I think to create a trigger that by a row_count I 'll able to trap this event. for example
CREATE TRIGGER TEST
AFTER
UPDATE
ON TRK_RDA
REFERENCING
OLD AS old NEW AS new
FOR EACH ROW
MODE DB2SQL
begin atomic
declare rcount integer;
get diagnostics rcount = row_count;
if ( rcount > 1 ) then
signal sqlstate '90920' (' Aggiornato piu di un record ');
end if;
end;

I Think that's a good idea but does not work. Someone can show me where I'm foul

Best thanks in advance

Sergio Pipitone

Nov 12 '05 #1
2 1335
eap90210 wrote:
Hi to all Ng

Sorry for my bad english.

I have got a problem. I understand if a user try to update more than 10
row in a table.

So I think to create a trigger that by a row_count I 'll able to trap
this event. for example

CREATE TRIGGER TEST
AFTER
UPDATE
ON TRK_RDA
REFERENCING
OLD AS old NEW AS new
FOR EACH ROW
MODE DB2SQL
begin atomic
declare rcount integer;
get diagnostics rcount = row_count;
if ( rcount > 1 ) then
signal sqlstate '90920' (' Aggiornato piu di un record ');
end if;
end;

I Think that's a good idea but does not work. Someone can show me where
I'm foul

Best thanks in advance

Sergio Pipitone

Sergio,

Try this:

CREATE TRIGGER TEST
AFTER
UPDATE
ON TRK_RDA
REFERENCING
NEW_TABLE AS new
FOR EACH STATEMENT
MODE DB2SQL
WHEN ((SELECT COUNT(1) FROM new) > 10)
signal sqlstate '90920' (' Aggiornato piu di un record ');

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
thanks
now the trigger working !!

best thank again
cheers
Sergio Pipitone

"Serge Rielau" <sr*****@ca.ibm.com> ha scritto nel messaggio
news:3q************@individual.net...
eap90210 wrote:
Hi to all Ng
Sorry for my bad english.
I have got a problem. I understand if a user try to update more than 10
row in a table.
So I think to create a trigger that by a row_count I 'll able to trap
this event. for example

CREATE TRIGGER TEST
AFTER
UPDATE
ON TRK_RDA
REFERENCING
OLD AS old NEW AS new
FOR EACH ROW
MODE DB2SQL
begin atomic
declare rcount integer;
get diagnostics rcount = row_count;
if ( rcount > 1 ) then
signal sqlstate '90920' (' Aggiornato piu di un record ');
end if;
end;

I Think that's a good idea but does not work. Someone can show me where
I'm foul

Best thanks in advance

Sergio Pipitone

Sergio,

Try this:

CREATE TRIGGER TEST
AFTER
UPDATE
ON TRK_RDA
REFERENCING
NEW_TABLE AS new
FOR EACH STATEMENT
MODE DB2SQL
WHEN ((SELECT COUNT(1) FROM new) > 10)
signal sqlstate '90920' (' Aggiornato piu di un record ');

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #3

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

Similar topics

1
by: Matik | last post by:
Hello to all, I have a small question. I call the SP outer the DB. The procedure deletes some record in table T1. The table T1 has a trigger after delete. This is very importand for me, that...
6
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...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
6
by: Mary | last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger" table containing numerous triggers - each of which is activated by an UPDATE to a different column of this "trigger" table. When...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
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...
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...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
7
by: Shane | last post by:
I have been instructed to write a trigger that effectively acts as a foreign key. The point (I think) is to get me used to writing triggers that dont use the primary key(s) I have created the...
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
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
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.