"Daniel Ordobas Bortolas" <bortolas(at)inf(dot)UFSM(dot)br> writes:
> -->create table loco( id_loco int4 not null, primary key (id_loco), check(
> (select count(*) from loco ) < 3 ) );
> ->insert into loco values(1);
> the result is: ERROR: ExecEvalExpr: unknown expression type 108
Subselects aren't supported in check constraints (and if you were
running a version newer than 7.0.*, it would've told you so ...)
Possibly you could do what you want with a trigger function.
regards, tom lane