Documente Academic
Documente Profesional
Documente Cultură
Objectives
If expr1 is null, NVL returns expr2. If expr1 is not null, NVL returns expr1.
The 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%';
TRANSLATE returns char with all occurrences of each character in from_string replaced by its corresponding character in to_string. Characters in char that are not in from_string are not replaced.
The following statement translates a license number. All letters 'ABC...Z' are translated to 'X' and all digits '012 . . . 9' are translated to '9': SELECT TRANSLATE('2KRW229', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '9999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') "License" FROM DUAL;
Pseudocolumns
Behaves like a table column Not stored in table Cannot change value of pseudocolumn
10
Pseudocolumns
CURRVAL NEXTVAL ROWID ROWNUM LEVEL(used for hierarchical queries)
11
Examples
SELECT empSeq.CURRVAL from DUAL; SELECT ROWID, ENAME FROM EMP; SELECT ROWNUM, ENAME FROM EMP order by ename;
12
Summary
To understand important SQL functions To understand pseudo columns
13
Thank You!
Copyright 2005, Infosys Technologies Ltd 14 ER/CORP/CRS/DB25/003 Version No. 2.0