NVL
Description of the illustration nvl.gif
NVL
lets you replace null (returned as a blank) with a string in the results of a query. Ifexpr1
is null, thenNVL
returnsexpr2
. Ifexpr1
is not null, thenNVL
returnsexpr1
.The arguments
expr1
andexpr2
can have any datatype. If their datatypes are different, then Oracle Database implicitly converts one to the other. If they are cannot be converted implicitly, the database returns an error. The implicit conversion is implemented as follows:
If
expr1
is character data, then Oracle Database convertsexpr2
to the datatype ofexpr1
before comparing them and returnsVARCHAR2
in the character set ofexpr1
.If
expr1
is numeric, then Oracle determines which argument has the highest numeric precedence, implicitly converts the other argument to that datatype, and returns that datatype.See Also:
Table 2-10, "Implicit Type Conversion Matrix" for more information on implicit conversion and "Numeric Precedence" for information on numeric precedenceThe following example returns a list of employee names and commissions, substituting "Not Applicable" if the employee receives no commission:
SELECT last_name, NVL(TO_CHAR(commission_pct), 'Not Applicable') "COMMISSION" FROM employees WHERE last_name LIKE 'B%' ORDER BY last_name; LAST_NAME COMMISSION ------------------------- ---------------------------------------- Baer Not Applicable Baida Not Applicable Banda .1 Bates .15 Bell Not Applicable Bernstein .25 Bissot Not Applicable Bloom .2 Bull Not Applicable
No. | Subject | Author | Date | Views |
---|---|---|---|---|
49 | Assign a network host to Access Control List | admin | 2016.06.07 | 352 |
48 | ADD_PRIVILEGE (2nd STEP) | admin | 2016.06.07 | 401 |
47 | CREATE_ACL (1st STEP) | admin | 2016.06.07 | 355 |
46 | ACL 보기 | admin | 2016.06.07 | 351 |
45 | Oracle 11g Access Control List for External Network Services | admin | 2016.06.07 | 340 |
44 | Access Control List (ACL) | admin | 2016.06.07 | 379 |
43 | CAPTCHA PLUG-IN | admin | 2016.05.27 | 363 |
42 | SUBSTR | admin | 2016.05.26 | 323 |
41 | FOR LOOP | admin | 2016.05.20 | 328 |
40 | ROWNUM | admin | 2016.05.19 | 289 |
» | NVL | admin | 2016.05.19 | 206 |
38 | INSTR | admin | 2016.05.19 | 870 |
37 | TREE | admin | 2016.05.18 | 811 |
36 | 3D Pie Chart | admin | 2016.05.17 | 295 |
35 | CREATE VIEW | admin | 2016.05.13 | 294 |
34 | test | admin | 2016.05.11 | 178 |
33 | BOOLEAN SAMPLE | admin | 2016.05.11 | 185 |
32 | Display Value, Return Value | admin | 2016.05.10 | 185 |
31 | Fundamentals of PL/SQL | admin | 2016.05.10 | 2107 |
30 | Interactive Report | admin | 2016.05.07 | 162 |