문제

SQL에 NVL () 동등한 함수가 있습니까?

아니면 특정 시나리오에서 같은 방식으로 사용하기에 충분히 가까운 것이 있습니까?


업데이트:
그렇지 않은 경우
사례 진술이 없습니다
isnull
Coalesce가 없습니다

select nvl (purge_date,"SODIUFOSDIUFSDOIFUDSF") from id_rec where id=36581;


(expression)

SODIUFOSDIUFSDOIFUDSF

1 row(s) retrieved.

select isnull (purge_date,"SODIUFOSDIUFSDOIFUDSF") from id_rec where id=36581;

  674: Routine (isnull) can not be resolved.
Error in line 1
Near character position 8

select coalesce (purge_date,"SODIUFOSDIUFSDOIFUDSF") from id_rec where id=36581;

  674: Routine (coalesce) can not be resolved.
Error in line 1
Near character position 8

select decode(purge_date, NULL, "01/01/2009", purge_date) from id_rec where id=74115;

  800: Corresponding types must be compatible in CASE expression.
Error in line 1
Near character position 57
도움이 되었습니까?

해결책

당신은 Informix를 사용하는 것 같습니다.

afaik, 거기에 디코딩이 있습니다.

DECODE(field, NULL, 'it is null, man', field) 당신에게 동일한 결과를 제공해야합니다 NVL(field, 'it is null, man')

사용중인 RDBM의 정확한 이름과 버전을 게시하십시오.

다른 팁

ISNULL (단일 교체 용)

또는

Coalesce (논쟁 중에서 첫 번째가 아닌 표현을 반환합니다.)

SQL Server : isnull 또는 Coalescehttp://msdn.microsoft.com/en-us/library/ms184325.aspx

Sybase : ISNULL 기능http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks162.htm

Postgres : 완전히 확인하지는 않았지만 찾을 수 없었습니다. NULL 위치를 선택하고 여기에서 빌드 할 것을 제안합니다.http://archives.postgresql.org/pgsql-sql/1998-06/msg00142.php

DB2- Coalescehttp://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0000780.htm

800 오류를 생성하는 Decode 문의 문제는 간단합니다. '01/01/2009' 문자열로 취급되고 있으며 실제로 오류를 생성하는 네 번째 인수입니다.

디코드 명령문의 입력 및 출력은 다른 데이터 유형이 될 수 있으므로이 경우 엔진이 더 명확해야합니다. (당신은 원하십니까? purge_date 문자열 또는 문자열로 캐스트합니다 '01/01/2009', 또는 문자열 인수는 날짜 또는 원래 날짜로 구문 분석 되었습니까? 엔진이 알 수있는 방법이 없습니다.

이 시도:

SELECT DECODE(purge_date, NULL, '01/01/2009'::DATE, purge_date)

또한 그 세 번째 인수를 다음과 같이 쓸 수도 있습니다.

    DATE('01/01/2009')
    MDY(1,1,2009)

버전 및 개인 선호도에 따라 다릅니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top