Home > Database > Mysql Tutorial > Oracle 判断字符串为''还是Null

Oracle 判断字符串为''还是Null

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:09:18
Original
1662 people have browsed it

Oracle 判断varchar2类型是不是为空

Oracle 判断varchar2类型是不是为空'' ,用什么判断符

VV_LIST:='DSSSFDFDSFDS';
IF(VV_LIST '')THEN
  DBMS_OUTPUT.PUT_LINE('PPPPPPPPPPPPPPPPP');
  ELSE
  DBMS_OUTPUT.PUT_LINE('BBBBBBBBBBBBBBBBBBBBBBBB');
  END IF;

结果却打印了BBBBBBBBBBBBBBBBBBBBBBBB


IF ('' IS NULL) THEN
  dbms_output.put_line(''''' is null');
  END IF;
输出:'' is null

这说明,在oracle pl/sql里,,把''当成null处理了


Oracle中的空应该用的是null,非空就是not null
for example:

SQL code
SQL code 所以可以这么做:


select   

st.koyu_zaisan_no
,st.koyu_zaisan_edaban
,st.shutoku_nendo  --?異動年度
,st.shutokubi          --?異動日
,st.kaikei
,'会計名'                 --?
,st.shukanka          --?
,'KANJYO_KAMOKU_MEISHO'  --?
,'金額'
,'err_no'                 --?
,'err_naiyo'            --?
,'0' csv_type          --?

from SHISAN_TAB st
where  trim(nvl(st.chiku_cd,'')) || 'A' ='A'
or  trim(nvl(st.chimoku,'')) || 'B' ='B'

linux

Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template