(a == 1&& a == 2&& a == 3)在pl sql中评估为true?

时间:2018-03-19 02:15:09

标签: plsql oracle11g

就像这里的一些问题,(a == 1&& a == 2&& a == 3)已被证明可以在javascript中评估为真,我只是想知道是否PL / SQL中还有一种方法可以将其评估为真。

1 个答案:

答案 0 :(得分:14)

当然是为了好玩

SQL> create or replace
  2  package pkg is
  3    x int := 0;
  4  end;
  5  /

Package created.

SQL>
SQL> create or replace
  2  function a return number is
  3  begin
  4    pkg.x := pkg.x + 1;
  5    return pkg.x;
  6  end;
  7  /

Function created.

SQL>
SQL>
SQL> set serverout on
SQL> begin
  2   if a = 1 and a = 2 and a = 3 then
  3     dbms_output.put_line('BINGO!');
  4   end if;
  5  end;
  6  /
BINGO!

PL/SQL procedure successfully completed.