Help with PostgreSQL constraint

Xeon SX

Well-Known Member
Joined
Feb 8, 2005
Messages
1,515
Location
London
I need to restict adding more than 4 rows to the table.

I tried this but it doesnt work:
CREATE VIEW count_rows AS SELECT COUNT(*) as yy FROM t6;
ALTER TABLE t6 ADD CONSTRAINT max_4_rows check(4<count_rows.yy);

please help...
 
Haven't seen threads with 0 replies for a long time here :(

anyway if anyone wants to know the solution:

CREATE OR REPLACE RULE max_4_rows AS
ON INSERT TO t6
WHERE 3 < (select count(*) from t6)
DO INSTEAD NOTHING;
 
Sorry I didn't reply: I'm a mySQL guy ;) but the syntax is similar.
 
Top