Greetings!
Last week I queries this community as I was looking for a way to set up an index on my table that performed the following: for any given value of aval_tplts_id, there are not 2 other rows (X and Y) such that X.aval_tplts_id_defined_by=Y.aval_tplts_alt_id_defined_by and
X.aval_tplts_alt_id_defined_by=Y.aval_tplts_id_defined_by.
I got several replies, all of them very helpful and was provided with the following piece of code:
CREATE UNIQUE INDEX dependency_unique
ON template_dependencies ( aval_tplts_id
, LEAST (aval_tplts_id_defined_by, aval_tplts_alt_id_defined_by)
, GREATEST (aval_tplts_id_defined_by, aval_tplts_alt_id_defined_by)
);
This works perfectly, except in cases where two rows of identical aval_tplts_id values also have a value of NULL for aval_tplts_alt_id_defined_by.
My initial thought was to insert a WHERE clause or similar somewhere in the index creation, though I don't see any way to do that directly in PL/SQL (I found some documentation for SQL Server involving this, though it doesn't appear to be a feature in Oracle).
Is there any way to create this index to ignore the value of aval_tplts_alt_id_defined_by when that value is NULL?