Posted on Sunday, 6th September 2009 by captainmi2

How to use null in PL\SQL
below are example:

declare
var_a varchar2(10) := null;
begin
if var_a = null then
dbms_output.put_line(’empty’);
else
dbms_output.put_line(’ not empty’);
end if;
end;

the above statement will output
“not empty” because the null is not use accordingly.
if the statement were use as below

declare
var_a varchar2(10) := null;
begin
if var_a is null then
dbms_output.put_line(’empty’);
else
dbms_output.put_line(’not empty’);
end if;
end;

this will return “empty”
This 2nd statement is the correct way [...]

Tags:
Posted in Basic, Oracle | Comments (0)