Use Declare keyword in trigger

Database

Use Declare keyword in trigger

Hello all!

Can I use declare keyword in trigger. If can how have I to do it?
E.g.
CREATE TRIGGER
trigger_name
AFTER INSERT ON
table_name
REFERENCING NEW ROW n_r
FOR EACH ROW(
DECLARE myvar INTEGER;-- error occurred: expected something between "(" and declare keyword.
...
);

Thank you for advance!

2 REPLIES
Senior Apprentice

Re: Use Declare keyword in trigger

You can't use DECLARE within a trigger, only Stored Procedures.

But you could call a SP from a trigger, i think since V2R6.2.

Btw, row triggers might be quite slow, better try to write a statement trigger...

Dieter

Re: Use Declare keyword in trigger

Thx, Dieter! You are right!