I would like to know how the following can be done through a trigger -
When session A inserts a row in a table I would like to check for uniqueness for one of the columns through the insert trigger before commiting the row. This works well for all rows which have already been commited but suppose another session B has inserted a row and session A has not commited it (B) does not "see" the row added by A and the check for uniqueness fails if both B and A have the same value for that column.
The interesting thing is it works when you put a unique constraint on the column (even if it is not commited). For some reason I do not want to put a constraint on the table but validate it through a trigger. Basically I want to know how the constraint does it so I could implement this in triggers.
When session A inserts a row in a table I would like to check for uniqueness for one of the columns through the insert trigger before commiting the row. This works well for all rows which have already been commited but suppose another session B has inserted a row and session A has not commited it (B) does not "see" the row added by A and the check for uniqueness fails if both B and A have the same value for that column.
The interesting thing is it works when you put a unique constraint on the column (even if it is not commited). For some reason I do not want to put a constraint on the table but validate it through a trigger. Basically I want to know how the constraint does it so I could implement this in triggers.