In PL/SQL the Boolean expression NULL=NULL evaluates to FALSE. : NULL « PL SQL Data Types « Oracle PL/SQL Tutorial

Home
Oracle PL/SQL Tutorial
1.Introduction
2.Query Select
3.Set
4.Insert Update Delete
5.Sequences
6.Table
7.Table Joins
8.View
9.Index
10.SQL Data Types
11.Character String Functions
12.Aggregate Functions
13.Date Timestamp Functions
14.Numerical Math Functions
15.Conversion Functions
16.Analytical Functions
17.Miscellaneous Functions
18.Regular Expressions Functions
19.Statistical Functions
20.Linear Regression Functions
21.PL SQL Data Types
22.PL SQL Statements
23.PL SQL Operators
24.PL SQL Programming
25.Cursor
26.Collections
27.Function Procedure Packages
28.Trigger
29.SQL PLUS Session Environment
30.System Tables Data Dictionary
31.System Packages
32.Object Oriented
33.XML
34.Large Objects
35.Transaction
36.User Privilege
Oracle PL/SQL Tutorial » PL SQL Data Types » NULL 
21.24.3.In PL/SQL the Boolean expression NULL=NULL evaluates to FALSE.

You need to wrap the selector in an NVL expression to be sure that it could never be NULL:

SQL> create or replace function f_getDateType (in_dt DATE)
  2  return VARCHAR2
  3  is
  4      v_out VARCHAR2(10);
  5  begin
  6      case nvl(to_char(in_dt,'d'0)
  7          when then
  8          -- value will be null if in_dt is null
  9              v_out:='<NULL>';
 10          when then
 11              v_out:='SUNDAY';
 12          when then
 13              v_out:='SATURDAY';
 14          else
 15              v_out:='WEEKDAY';
 16      end case;
 17      return v_out;
 18  end;
 19  /

Function created.

SQL>
SQL>
21.24.NULL
21.24.1.All logical operations (including NOT) involving NULL always return NULL
21.24.2.variable:=nvl(value1,value2);
21.24.3.In PL/SQL the Boolean expression NULL=NULL evaluates to FALSE.
21.24.4.Short-circuit evaluation with conditional structures.
21.24.5.Compare with NULL value for equality
21.24.6.Compare with NULL value for non-equality
21.24.7.Compare NULL value and OR operator
21.24.8.Compare with NULL value and 'AND' operator
21.24.9.Compare Integer value with NULL value
21.24.10.Use IS NULL in IF statement
21.24.11.Use NVL in IF statement to deal with the NULL value comparison
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.