By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,287 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,287 IT Pros & Developers. It's quick & easy.

Trigger Db2 V8.xx

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.