I am curious to know is it possible to create a conditional not null constraint in sql? In otherwords is it possible to create a constraint such that a column B can be null
Edit: as mentioned in the other answers, a CHECK is the best method, not the trigger I originally suggested. Original text follows:
As dbaseman suggests, triggers are the way to go (not so). Try something like this (untested):
CREATE OR REPLACE TRIGGER test
BEFORE UPDATE ON table1
FOR EACH ROW
WHEN (new.A = 'NEW' and new.B IS NOT NULL)
RAISE_APPLICATION_ERROR (
num=> -20001,
msg=> 'B must be NULL for new rows (A = NEW)'
);