There is a table:

CREATE TABLE task ( id SERIAL PRIMARY KEY, time_spent TIMESTAMP CONSTRAINT DF_task_time_spent DEFAULT NULL, closedAt TIMESTAMP CONSTRAINT DF_task_closedAt DEFAULT NULL); 

It is necessary to check with constraints (constraints), if the closedAt field is NULL, then time_spent can be edited, if closedAt = NULL, then editing time_spent is prohibited.

Is it possible to do without triggers? Thank.

  • one
    There are no constraints that check the OPERATION. They check only the final state. - Akina

0