Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1121

How to return a default value if lookup fails on a table

$
0
0
given this table:


CREATE TABLE "ACME_ERRORCODES"
( "ERRORCODE" VARCHAR2(100 BYTE),
"ISRETRIABLE" NUMBER,
"ISCUSTOM" NUMBER
) ;



if you want to return a default value 0 for ISRETRIABLE in case the ERRORCODE is missing in the table, you can do:


select NVL (
(select ISRETRIABLE from ACME_ERRORCODES where errorcode = 'SOME_MISSING_ERROR_CODE' ),
'0')
from dual;



Viewing all articles
Browse latest Browse all 1121

Trending Articles