plsql中的布尔算术

时间:2012-05-28 09:12:09

标签: oracle plsql

我有一组pl / sql函数,都返回一个布尔类型 我从另一个pl / sql函数中逐个调用这些函数。我想"积累"结果并从该函数返回它。

例如:

  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;

我想知道,我可以在pl / sql中进行布尔运算吗? 我的意思是这样的:

  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;

我试过了:

v_res := v_res * false;

v_res := v_res and false;

但唯一似乎有效的是将布尔值转换为int(我尝试使用sys.diutil.bool_to_int),这感觉不对......

1 个答案:

答案 0 :(得分:3)

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