Doubt in Null and Empty String [message #249634] |
Thu, 05 July 2007 07:16 |
balaji23_d
Messages: 123 Registered: February 2007
|
Senior Member |
|
|
I'm running 10.2.0.2. Note the difference in behavior between passing and explicit NULL in the parameter vice passing an empty string (''):
CREATE OR REPLACE PROCEDURE NULL_ES_TEST(PARAM1 IN VARCHAR2) IS
VAR1 CHAR(1);
BEGIN
IF PARAM1 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('PARAM1 IS NULL');
END IF;
VAR1 := PARAM1;
IF VAR1 IS NULL THEN
DBMS_OUTPUT.PUT_LINE('VAR1 IS NULL');
ELSE
DBMS_OUTPUT.PUT_LINE('VAR1 IS NOT NULL');
END IF;
DBMS_OUTPUT.PUT_LINE('THE LENGTH OF VAR1 IS '||TO_CHAR(LENGTH(VAR1)));
END NULL_ES_TEST;
EXEC NULL_ES_TEST(PARAM1 => '');
PARAM1 IS NULL
VAR1 IS NOT NULL
THE LENGTH OF VAR1 IS 1
(var1 now holds a single space)
EXEC NULL_ES_TEST(PARAM1 => NULL);
PARAM1 IS NULL
VAR1 IS NULL
THE LENGTH OF VAR1 IS
Any Comments or Insights are welcome.
|
|
|
|
|
|