Re: Warnings of using uninitialized variables in PL/SQL

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 20 Nov 2001 10:05:09 -0800
Message-ID: <9te60l0289o_at_drn.newsguy.com>


In article <888c8e58.0111200651.35c870_at_posting.google.com>, vallka_at_hotmail.com says...
>
>Every modern compiler has such a feature. If there any possibility to
>track this in PL/SQL? E.g.
>
>create procedure Foo
>is
> n number;
>begin
> insert into bar i values (n);
> commit;
> n := 8;
>end;
>
>Using a code like this will produce a warning in about any compiler
>for any language (C++, Java, Perl...), providing warnings are turned
>on. But what about PL/SQL? How to turn on warnings for Pl/SQL?

Unlike other languages, NULL is perfectly valid. Whereas referencing a NULL object in Java is fatal, referencing a null object in PLSQL is perfectly valid, accepted and quite noraml. The variable is in fact initialized -- to NULL.

NULLS are just another value for variables in PLSQL (SQL actually). There is no such compiler checking.

--
Thomas Kyte (tkyte_at_us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Tue Nov 20 2001 - 19:05:09 CET

Original text of this message