Subject Re: [firebird-support] A few questions
Author Martijn Tonies
> 1) It appears the check constraint below it not enforced properly. Why ?
>
> create table tt ( k numeric(8) , v char(10));
> alter table tt add constraint ck1 check( 3>(select count(*) from tt) );
> insert into table tt(k,v) values (1,'one');
> insert into table tt(k,v) values (2,'two');
> insert into table tt(k,v) values (3,'three');
> This
> insert into table tt(k,v) values (4,'four');
> results in
> "Operation violates CHECK constraint CK1 on view or table TT"
>
> select count(*) from tt;
> count
> ------
> 3

A Check Constraint is evaluated before every update or insert. If
it passes, the statement passes. So in your case, I guess you need
to write CHECK (2 > ( ... ) )

> 2)There are STATEMENT triggers in Firebird ?

No, only row level triggers.

>If not, is there a way to
> simulate them ?

Wouldn't know how.

> 3) How can I retrieve the count of the row affected by the previous DML
> statement in a stored procedure ?

In Firebird 1.5 ( I believe ) and up, use the ROW_COUNT variable.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com