Subject Re: INSERT ... RETURNING and updatable view
Author ettotev
--- In firebird-support@yahoogroups.com, Paul Vinkenoog wrote:
....
>
> It is often more useful to define the BI trigger as:
>
> create trigger T_BI for T before insert as
> begin
> if (new.ID is null) then new.ID = next value for SEQ;
> end^
>
> (but if you had done that, you wouldn't have detected the inconsistency below ;-))

Well, I've seen that but I don't like the idea. An auto-generated ID should be auto-generated in all cases. Imagine for example someone inserting a random higher value that will one day come into conflict with the sequence-generated...

....
>
> insert into T values (new.ID) returning T.id into :new.id;
>
> That would solve the whole problem (he said without having tested it).

Yes, that works, but I consider it a workaround :)
The same thing happens for calculated and DEFAULT fields as well.

Thanks
Emil