Home >> FAQs/Tutorials >> Oracle Tutorials

Oracle Tutorials - Test NULL Values

By: FYIcenter.com

(Continued from previous topic...)

How To Test NULL Values?

There ate two special comparison operators you can use on NULL values:

  • "variable IS NULL" - Returns TRUE if the variable value is NULL.
  • "variable IS NOT NULL" - Return TRUE if the variable value is not NULL.

The following sample script shows you examples of comparing NULL values:

DECLARE
  next_task CHAR(80);
BEGIN
  next_task := NULL;

  IF next_task IS NOT NULL THEN
     DBMS_OUTPUT.PUT_LINE('I am busy.');
  ELSE
     DBMS_OUTPUT.PUT_LINE('I am free.');
  END IF;
  
  IF next_task IS NULL THEN
     NULL;
  ELSE
     DBMS_OUTPUT.PUT_LINE('... working on ' || next_task);
  END IF;
END;

Note that "variable = NULL" is not a valid operation. This script should print this:

I am free.

  1. Is PL/SQL Language Case Sensitive?
  2. How To Enter Comments in PL/SQL?
  3. What Are the Types of PL/SQL Code Blocks?
  4. What Is an Anonymous Block?
  5. What Is a Named Program Unit?
  6. What Is a Procedure?
  7. What Is a Function?
  8. How To Declare a Local Variable?
  9. How To Initialize Variables with Default Values?
  10. How To Assign Values to Variables?
  11. What Are the Arithmetic Operations?
  12. What Are the Numeric Comparison Operations?
  13. What Are the Logical Operations?
  14. How Many Categories of Data Types?
  15. How Many Scalar Data Types Are Supported in PL/SQL?
  16. How To Convert Character Types to Numeric Types?
  17. What Are the Execution Control Statements?
  18. How To Use "IF" Statements on Multiple Conditions?
  19. How To Use "WHILE" Loop Statements?
  20. How To Use "FOR" Loop Statements?
  21. What Is NULL in PL/SQL?
  22. How To Test NULL Values?

Oracle Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...