Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Operators
 

IS NULL

The IS NULL operator is used to test a NULL value. Variables you declare in a PL/SQL block are also initially null, or have no value. Variables remain null until your code specifically assigns a value to them. The Syntax for IS NULL: the_value IS [NOT] NULL the_value is a variable, or another expression. If the value is null, then the IS NULL operator returns true. You can also reverse the test by using IS NOT NULL. SQL> SQL> --Remember to execute: SET SERVEROUTPUT ON SQL> DECLARE   2    test  INTEGER;   3  BEGIN   4    IF test IS NULL THEN   5      DBMS_OUTPUT.PUT_LINE('The variable TEST is null.');   6    END IF;   7     test := 1;   8     DBMS_OUTPUT.PUT_LINE('TEST = ' || TO_CHAR(test));   9     IF test IS NOT NULL THEN  10       DBMS_OUTPUT.PUT_LINE('The variable TEST is NOT null.');  11     END IF;  12  END;  13  / The variable TEST is null. TEST = 1 The variable TEST is NOT null. PL/SQL procedure successfully completed. SQL>