Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Why I need to initialize this varable to NULL

Re: Why I need to initialize this varable to NULL

From: Jeff Smith <jsmit234_at_ford.com>
Date: Mon, 23 Sep 2002 08:49:39 -0400
Message-ID: <amn2l3$jbp4@eccws12.dearborn.ford.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US