Subject Re: [firebird-support] bde error caused by trigger
Author Helen Borrie
At 12:11 PM 18/11/2003 +0100, you wrote:

>Hello,
>
>I have this trigger (thanks to heLen for her help):
>
>CREATE TRIGGER CREATE_PERS_NUMBER FOR WT_PERS
>INACTIVE BEFORE INSERT POSITION 0
>as
>DECLARE VARIABLE prefix varchar(5);
>begin
>/* if (NEW.PERS_NUMBER is null) then NEW.PERS_NUMBER =
>gen_id(gen_pers_number, 1); */
> NEW.PERS_NUMBER = gen_id(gen_pers_number, 1);

*****************************************
Here's the original suggested code from last Sunday:

>
>How would such a trigger/stored proc look like?

set term ^;
create trigger bi_WT_PERS for WT_PERS
active before insert position 0 as
begin
if (NEW.PERS_NUMBER is null) then
NEW.PERS_NUMBER = cast(gen_id(gen_pers_number, 1) as varchar(20));
end ^
set term ;^

**************************
Fix up the data type mis-matching and at least *that* error will go away.

h.