I'm working with oracle for the first time, and I have a table called ExpenseReport which stores details about expenses.
I want Nulls to be allowed for ApprUserNo IF ERStatus = 'PENDING' Any help would be greatly appreciated, I've been trying to sort this all morning
CREATE TABLE ExpenseReport
(
ERNo NUMBER(10) NOT NULL,
ERDesc VARCHAR2(255) NOT NULL,
ERSubmitDate DATE NOT NULL,
ERStatusDate DATE NOT NULL,
ERStatus VARCHAR2(8) DEFAULT 'PENDING' NOT NULL,
SubmitUserNo NUMBER(10) NOT NULL,
ApprUserNo NUMBER(10) NOT NULL CONSTRAINT BEN_Check CHECK (ERStatus LIKE('PENDING')),
UsersUserNo NUMBER(10) NOT NULL,
AssetAssetNo NUMBER(10) NOT NULL,
PRIMARY KEY (ERNo),
CONSTRAINT Check_ER_Date CHECK (ERStatusDate >= ERSubmitDate),
CONSTRAINT ERStatus_Null_Exception CHECK (IF ERStatus = 'PENDING',AppUserNo = NULLABLE),
CONSTRAINT ERStatus_Option CHECK (ERStatus = 'PENDING','APPROBED','DENIED')
)