Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dealing with nulls in pl/sql

francy77May 22 2018 — edited May 24 2018

Hi all,

i'm asking how to manage nulls value in a pl sql procedure in a better way;

I have this fragment of a store procedure pl/sql

w_circ_1 := TH_PKG.GET_CIRC_TCD(P_Param);

w_circ_2 := TH_PKG.GET_CIRC_TW(P_Param);

IF val in (w_circ_1,w_circ_2 ) then

     --do something

else

    --do otherthing

end if;

and

w_circ_1 := nvl(TH_PKG.GET_CIRC_TCD(P_Param), '*');

w_circ_2 := nvl(TH_PKG.GET_CIRC_TW(P_Param), '*');

IF val in (w_circ_1,w_circ_2 ) then

    --do something

else

   --do otherthing

end if;

So in the second block the nulls value are substituted with an *, and in this way the IF statment make a comparision using the in operator with (*,*).

while in the first case the compare as it was (null,null);

I 've seen that both case works correctely, but I'm asking if there is one that is better from the other and way.

thanks really much

This post has been answered by Frank Kulash on May 22 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2018
Added on May 22 2018
22 comments
705 views