Subject Re: [ib-support] Re: Validation error
Author Marco Bommeljé
Hello again Magnus,

> Check out the following code:
> ... <
> 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 ;^

> /* -------- code part 2 - provoke the error ------------ */
> /* 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);
> /* validation error!! */
> -------- end of code -----------

I was surprised to see that the first insert works at all when the
trigger was put in place. The Ib6 documentation (DataDefinition guide
page 190) suggests otherwise:

<quote>
InterBase does not perform writethroughs on any view that has one or
more triggers defined on it.
</quote>

This implies that the validation error on the second statement is not
a bug. In stead, the fact that your first statement works at all (when
the trigger is in place) should be considered as an undocumented
feature. ("Works as programmed" was an answer we once received from a
technology vendor; "works as designed" would mean there is a design.)

Good luck,
Marco

--
-------------------------------------
-- Marco Bommeljé
-- Bommeljé Crompvoets en partners bv
-- W: www.bcp-software.nl
-- E: mbommelj@...
-- T: +31 (0)30 2428369
-------------------------------------