Subject Re: [firebird-support] Naturally updatable views
Author Helen Borrie
At 05:14 AM 19/02/2009, you wrote:
>Hello,
> I'm after some clarification about something I have read in the
>firebird book. It says that views are not naturally updatable if the
>view does not select all of the not null fields in a table. Is that
>strictly true?

Yes. Note *naturally* updatable.

>I'm just starting to use views and it seems that if the
>field that is not included in the view is updated by a default value or
>a trigger then the view will still be updatable.

Views that are not naturally updatable can be made updatable if you have before insert triggers to take care of the non-nullable fields. If you declare a default for a non-nullable field and don't include that field in your insert or update set then it will kick in in time to save you from a constraint error.

If you're using > Fb 1.5, make sure you read the release notes or language updates as well. The rules for views have been subtly changing from release to release.

>Am I correct on this

Perhaps not very clear what "naturally updatable" means. The book does describe the difference in quite some detail.

>or am I likely to get bitten further down the line?

People get bitten further down the line when they rely on guesswork. ;-) Always test both execution and results of anything that's designed to change data.

./hb