21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DDL statements<br />

Description: From <strong>Firebird</strong> 2.0 onward view definitions are considered full-fledged SELECT statements. Consequently,<br />

the following elements are (re)allowed in view definitions: FIRST, SKIP, ROWS, ORDER BY, PLAN<br />

and UNION.<br />

Note<br />

The use of a UNION within a view is currently only supported if you supply a column list for the view (this<br />

list is normally optional):<br />

create view vplanes (make, model) as<br />

select make, model from jets<br />

union<br />

select make, model from props<br />

union<br />

select make, model from gliders<br />

In <strong>Firebird</strong> 2.5, the column list will become optional also for views with UNIONs.<br />

PLAN subclause disallowed in 1.5, reallowed in 2.0<br />

Changed in: 1.5, 2.0<br />

Description: <strong>Firebird</strong> versions 1.5.x forbid the use of a PLAN subclause in a view definition. From 2.0 onward<br />

a PLAN is allowed again.<br />

Triggers on updatable views block auto-writethrough<br />

Changed in: 2.0<br />

Description: In versions prior to 2.0, <strong>Firebird</strong> often did not block the automatic writethrough to the underlying<br />

table if one or more triggers were defined on a naturally updatable view. This could cause mutations to be<br />

performed twice unintentionally, sometimes leading to data corruption and other mishaps. Starting at <strong>Firebird</strong><br />

2.0, this misbehaviour has been corrected: now if you define a trigger on a naturally updatable view, no mutations<br />

to the view will be automatically passed on to the table; either your trigger takes care of that, or nothing will.<br />

This is in accordance with the description in the InterBase 6 Data Definition Guide under Updating views with<br />

triggers.<br />

Warning<br />

Some people have developed code that counts on or takes advantage of the prior behaviour. Such code should<br />

be corrected for <strong>Firebird</strong> 2.0 and higher, or mutations may not reach the table at all.<br />

View with non-participating NOT NULL columns in base table can be made<br />

insertable<br />

Changed in: 2.0<br />

Description: Any view whose base table contains one or more non-participating NOT NULL columns is readonly<br />

by nature. It can be made updatable by the use of triggers, but even with those, all INSERT attempts into<br />

such views used to fail because the NOT NULL constraint on the base table was checked before the view trigger<br />

54

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!