what is the default value of a variable (VARCHAR2) at the time of declaration in PL SQL? Can i check it against NULL once after i declare a variable?
+9
A:
Variables are default initialized with NULL.
You can change that, for example:
create procedure show1
as
l_start varchar2(10) := 'Hello';
begin
if l_start is not null then
....
end if;
end;
/
You can also declare variables as not nullable:
create procedure show2
as
l_start varchar2(10) not null := 'Hello';
begin
null;
end;
/
tuinstoel
2009-08-29 05:21:06
A:
tuinstoel is correct.
One addition: Don't be fooled into trying "ls_my_variable = NULL" as comparing with NULL always returns FALSE. Always use "ls_my_variable IS NULL" or "IS NOT NULL".
darreljnz
2009-08-30 10:38:35
A:
And another small addition: if you're dealing with BLOBs (or CLOBS), "empty" is not the same as null. See the Oracle large objects manual if you need to.
Jim Hudson
2009-08-31 14:56:42