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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DDL statements<br />

got a chance to put things right. In <strong>Firebird</strong> 2.0 and up this is no longer the case: provided the right trigger is<br />

in place, such views are now insertable.<br />

Example:<br />

Notes:<br />

The view below would give validation errors for any insert attempts in <strong>Firebird</strong> 1.5 and earlier. In<br />

<strong>Firebird</strong> 2.0 and up it is insertable:<br />

create table base (x int not null, y int not null);<br />

create view vbase as select x from base;<br />

set term #;<br />

create trigger bi_base for vbase before insert<br />

as<br />

begin<br />

if (new.x is null) then new.x = 33;<br />

insert into base values (new.x, 0);<br />

end#<br />

set term ;#<br />

• Please notice that the problem described above only occurred for NOT NULL columns that were left outside<br />

the view.<br />

• Oddly enough, the problem would be gone if the base table itself had a trigger converting NULL input to<br />

something valid. But then there was a risk that the insert would take place twice, due to the auto-writethrough<br />

bug that has also been fixed in <strong>Firebird</strong> 2.<br />

RECREATE VIEW<br />

Available in: DSQL<br />

Added in: 1.5<br />

Description: Creates or recreates a view. If a view with the same name already exists, RECREATE VIEW will<br />

try to drop it and create a new view. RECREATE VIEW will fail if the existing view is in use.<br />

Syntax: Exactly the same as CREATE VIEW.<br />

55

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

Saved successfully!

Ooh no, something went wrong!