Subject Validation error
Author semprolbat
Hi.

I am experiencing a weird validation error:

I have a table with a field (Field2) that is not nullable, and has
the default value of 0. My users access the table via a view.

When a user inserts values in the view, omitting Field2, Firebird is
supposed to set the field's value to 0. This works great, until I add
an insert trigger to the view. The result of adding the trigger is
that Firebird no longer sets the field's value to 0, but returns a
validation error instead.

Check out the following code:

-------- code part 1 - create the database ------------
create database "TestDB.gdb" user "sysdba" password "masterkey";

create table TestTable (
Field1 integer,
Field2 integer default 0 not null
);

create view TestView as
select
Field1,
Field2
from
TestTable;


set term ^;

create trigger ti_testview
for testview
before insert
as
declare variable v_test integer;
begin
v_test=1;
end^

set term ;^


grant all on TestView to SomeUser;

-------- code part 2 - provoke the error ------------
connect "TestDB.gdb" user SomeUser password SomePassword;

/* firstly we include Field2, which works great */
insert into testview (Field1,Field2)
values (1,0);

/* secondly we trust FireBird to set Field2's value to 0 */
insert into testview (Field1)
values (1);



-------- end of code -----------

When running the same code, omitting the insert trigger, both inserts
work great.

FireBird bug, or am I doing something wrong!???
I am running FireBird 1.0.2.908 win32.


Yours,
Magnus