Subject | RE: [firebird-support] bde error caused by trigger |
---|---|
Author | Yves Glodt |
Post date | 2003-11-18T12:03:02Z |
>> I have this trigger (thanks to heLen for her help):In the table it's a varchar(20) field, but it contains only integers.
>>
>> 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...
That's why I pad it with zeros. (btw is there a nicer way to do this?)
Note that this trigger works fine when I do manual inserts in isql!
But it fails when the app wants to insert records.
Any yes, it is activated (opposed to the script above)
> Alan
>
>
>
> To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/