Why does the IS NULL stament work diferent for Varchar2 and char
437319Jan 28 2005 — edited Jan 31 2005Why does the IS NULL stament work diferent for Varchar2,varchar and char?
The next procedure can explain what I'm talking about:
CREATE OR REPLACE PROCEDURE try_isnull IS
n VARCHAR(10):='';
n2 VARCHAR2(10):='';
n3 CHAR(10):='';
BEGIN
--Without space
IF n IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N is NULL');
END IF;
IF n2 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N2 is NULL');
END IF;
IF n3 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N3 is NULL');
END IF;
n:=' ';
n2:=' ';
n3:=' ';
--With space
IF n IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N is NULL');
END IF;
IF n2 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N2 is NULL');
END IF;
IF n3 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N3 is NULL');
END IF;
n:= NULL;
n2:=NULL;
n3:=NULL;
--With NULL
IF n IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N is NULL');
END IF;
IF n2 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N2 is NULL');
END IF;
IF n3 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('N3 is NULL');
END IF;
END;
Why Do they work different ? For me NULL is nothing, So, the rigth behavor should be the char behave.
Does somebody have any answer?