Tuesday, October 9, 2018

Replace Null Values on the Results Returned by ODBC Queries

Question: How to replace NULL values on the results returned by ODBC queries.
 
Answer:
 
Use the NVL() function as this is used to replace NULL values with another value.
 
For example:
 
a. This query: SELECT VENDOR_ID, VENDOR_EXTID FROM VENDORS; returns the result set shown below:
 
VENDOR_ID   |   VENDOR_EXTID
14                       890
15                       
 
 
b. For reporting purposes, use the NVL() function to change the NULL values. This is a sample query: SELECT VENDOR_ID, NVL(VENDOR_EXTID, 'No External ID for this Vendor') FROM VENDORS
 
This is the expected result:
 
VENDOR_ID   |   VENDOR_EXTID
14                       890
15                       No External ID for this Vendor

No comments:

Post a Comment