Using a Postgres DB. I have a table let say
t with columns
txn_type, txn_id. I want to add a constraint where it restricts to insert new row if I have a row with particular values existing in table.
e. g row 1
I am trying to add a constraint where it restricts to insert new row with
txn_type <> 'withdrawal' and
txn_id = txn1.
e.g it restricts to insert row with following values
My situation is like if a record exist with
transaction_type = withdrawal &
txnid=txn1 then no non-withdrawal record with same txn id should be able to be inserted.