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!

nvl equivalent for boolean statements?

523861Nov 11 2010 — edited Nov 11 2010
Hi guys,

just got asked this question by a delphi programmer - apparently assignments to variables can be made in a similar way to the following:
v_assignee := <boolean statement> : <result if true> : <result if false>
or basically what an nvl would do if it assessed trueness rather than nullness.

I've been using Oracle for quite a while and don't know of any such function (what's wrong with a case or if statement?) but I thought I'd ask the question anyway - does such a thing exist in Oracle?


i.e. :
declare

v_assignee number;

function assess (v_statement in boolean
                ,v_val1      in number
                ,v_val2      in number)
return number
is
begin

  if v_statement then
     return v_val1;
  else
     return v_val2;
  end if;

end;                 

begin

-- v_test := 
v_assignee := assess(1+1=2,10,20);

dbms_output.put_line(v_assignee);


end;
This post has been answered by Frank Kulash on Nov 11 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2010
Added on Nov 11 2010
1 comment
1,606 views