Bassal
Bassal

Reputation: 157

Boolean arithmetics in plsql

I have a set of pl/sql functions, all returning a boolean type.
I call these function from another pl/sql function one by one. I want to "accumulate" the results and return it from that function.

For example:

  v_res  boolean;
  v_res2 boolean := true;
begin
  v_res := f1('aa');
  if v_res = false then
    v_res2 := false;
  end if;

  v_res := f2('aa');
  if v_res = false then
    v_res2 := false;
  end if;

  -- some other calls to other functions

  return v_res2;
end;

I was wondering, can I do boolean arithmetic in pl/sql ?
I mean something like this:

  v_res boolean := true;
begin
  v_res := v_res * f1('aa');
  v_res := v_res * f2('aa');
  -- more calls to functions
  return v_res;
end;

I tried:

v_res := v_res * false;

and

v_res := v_res and false;

but the only thing that seems to work was converting the boolean to an int (I tried with sys.diutil.bool_to_int) which doesn't feel right ...

Upvotes: 0

Views: 269

Answers (1)

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60292

begin
  return f1('aa')
     and f2('aa')
     ... etc. ...
     ;
end;

Upvotes: 3

Related Questions