Basic Oracle Concepts and Programming Question:
Download Job Interview Questions and Answers PDF
How To Test NULL Values?
Answer:
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.
► "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.
Download Oracle Database Interview Questions And Answers
PDF
Previous Question | Next Question |
What Is NULL in PL/SQL? | What Is a Procedure in Oracle? |