Add a check constraint with the logic: ALTER TABLE test ADD CONSTRAINT aaa_atrib_2_not_null CHECK ( CASE WHEN attrib_1 = 'AAA'::text THEN attrib_2 IS NOT NULL ELSE true END);
-Mike On 26 April 2012 08:34, Piotr Pachół <piotrpac...@gmail.com> wrote: > Hello, > Is it possible to add constraint to second attribute of table only in the > situation when first attribute of table equals specified value ? > I give an example: > > CREATE TABLE test ( > attrib_1 text, > attrib_2 text > ); > INSERT INTO test VALUES ('AAA', 'QQQ'); > INSERT INTO test VALUES ('BBB', 'PPP'); > > > So is it possible to add constraint (for instance NOT NULL) to attrib_2 > column if attrib_1 = 'AAA' > > Regards, > Piotr > > _______________________________________________ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users