Subject | RE: [firebird-support] bde error caused by trigger |
---|---|
Author | Alan McDonald |
Post date | 2003-11-18T11:56:25Z |
> I have this trigger (thanks to heLen for her help):What is NEW.PERS_NUMBER?
>
> 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
>
at first it's an intetger (to get an increment from the generator..
but later it's a varchar...
Alan