Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Compare NULL value in WHERE clause

Compare NULL value in WHERE clause

From: <suisum_at_freenet.edmonton.ab.ca>
Date: 10 Oct 1998 15:00:31 GMT
Message-ID: <6vnsqf$emk$1@news.sas.ab.ca>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US