Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Compare NULL value in WHERE clause
If I want have the following data:
Field1 - NOT NULL Field2 - NULL Field3 - NULL
The access key to retrieve a record is the combination of Field1, Field2, and Field3. If I use the following statement, the query will fail becasue of the NULL value:
SELECT *
FROM my_table
WHERE Field1 = v_field1 AND Field2 = v_field2 AND Field3 = v_field3;
Is there any better way to make the select statement more generic before I use the following statement:
SELECT *
FROM my_table
WHERE NVL(Field1, '/') = NVL(v_field1, '/') AND NVL(Field2, '/') = NVL(v_field2, '/') AND NVL(Field3, '/') = NVL(v_field3, '/');
--
Best regards,
Received on Sat Oct 10 1998 - 10:00:31 CDT