Subject Re: [firebird-support] Trigger trouble when moving DB script from FB 1.5 to FB 2.0, please help.
Author Milan Babuskov
Chuck Belanger wrote:
> CREATE TRIGGER CUSTOM_VIEW_AI0 FOR CUSTOM_VIEW
> ACTIVE AFTER INSERT POSITION 0
> AS
> begin
> /* auto fill the Orig_CV_ID field when adding a new item */
> IF (NEW.ORIG_CV_ID IS NULL) THEN
> New.ORIG_CV_ID = New.CV_ID;
> end
> ;

Changing the value for NEW.something in AFTER trigger has no effect. FB
2.0 prevents you from thinking your code does something while it really
has no effect.

Looks like your database has subtle logic bugs you were not aware of
until now.


> The next statement causes the following error:
>
> Column does not belong to referenced table.
> Dynamic SQL Error.
> SQL error code = -206.
> Column unknown.
> OLD_TABLE_ID.
> At line 6, column 19.
> *******************************************************************************/
> CREATE TRIGGER CV_TABLE_AI0 FOR CV_TABLE
> ACTIVE AFTER INSERT POSITION 0
> AS
> begin
> /* auto fill the Old_ID field when adding a new item */
> IF (OLD_TABLE_ID IS NULL) THEN
> OLD_TABLE_ID = CV_TABLE_ID;
> end
> ;

Maybe you wanted: OLD.TABLE_ID instead of OLD_TABLE_ID ?


--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com