Subject RE: [firebird-support] bde error caused by trigger
Author Alan McDonald
> 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);
> if ((NEW.PERS_NUMBER >= 0) and (NEW.PERS_NUMBER < 10)) then
> prefix = '0000';
> if ((NEW.PERS_NUMBER >= 10) and (NEW.PERS_NUMBER < 100))
> then prefix =
> '000';
> if ((NEW.PERS_NUMBER >= 100) and (NEW.PERS_NUMBER < 1000))
> then prefix =
> '00';
> if ((NEW.PERS_NUMBER >= 1000) and (NEW.PERS_NUMBER <
> 10000)) then prefix
> = '0';
> NEW.PERS_NUMBER = prefix || cast(NEW.PERS_NUMBER as varchar(20));
> end
>

What is NEW.PERS_NUMBER?
at first it's an intetger (to get an increment from the generator..
but later it's a varchar...

Alan