Home  >  Article  >  Database  >  Oracle一则诡异的程序

Oracle一则诡异的程序

WBOY
WBOYOriginal
2016-06-07 17:45:47875browse

function chkA_B return varchar2 as

  a   varchar2(10):=NULL;

  b   varchar2(10):='1';

  begin

  if a=b then

  return 'Error';

  end if;

  return 'ok';

  end;

  这段程序诡异地返回ok,而不是Error. 通过跟踪,程序进入了 return 'error' .但是紧接着也执行了return 'ok'.

  如果将if 的条件改为 if nvl(a,'0')=b 则程序正常。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn