views:

40

answers:

2

Is it possible to have a CHECK under the form:

CREATE TABLE abc (no INTEGER, det INTEGER NOT NULL,
quo INTEGER CHECK (quo < AVG(st.quo)),
qoh INTEGER CHECK (qoh >= 0));

So basically every time new values are entered to check the average of quo of another (existing) table in the database and if and only if it's lower than the average of that table to allow new data to be inserted in the table?

+2  A: 

No. If you want that kind of check, you will have to write a trigger.

Pablo Santa Cruz
true, figured out! Thanks!
bsuv
+1  A: 

You need to do that in a trigger.

HLGEM