Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Why I need to initialize this varable to NULL
You don't need to initialize it... in your example it is null. If you wanted
to initialize it to some other other value, you could do it in the declare
block instead of after the BEGIN
DECLARE
v_a VARCHAR2(10) := 'FOO';
BEGIN
IF someThingHappen THEN
v_a:=someNewValue;
ND IF;
o_a:= v_a;
END A; Booleans in PL/SQL will need to be initialized to TRUE/FALSE.
"C Chang" <cschang_at_maxinter.net> wrote in message
news:3D8E9299.555F_at_maxinter.net...
> I got a little confused here. Say i have a procedure
> Procedure A ( .., o_a OUT VARCHAR2(10) )
>
> v_a VARCHAR2(10);
>
> BEGIN
>
> v_a := NULL;
>
> ..
> ..
> IF someThingHappen THEN
> v_a:=someNewValue;
> END IF;
>
> o_a:= v_a;
>
> END A;
>
> Why I need to initialize the v_a:=NULL in BEGIN section? AS I read the
> PL/SQL guide, that in procedure body when v_a was created, its default
> value is NULL as its type is VARCHAR2(10). So if someThingHappen is not
> there, v_a should be automatically as NULL. Am I right? Thanks anyone
> clear out this for me.
>
> C Chang
Received on Mon Sep 23 2002 - 07:49:39 CDT