Plsql using NVL [message #686272] |
Tue, 19 July 2022 14:21  |
 |
Unclefool
Messages: 65 Registered: August 2021
|
Member |
|
|
Apologies for the question but I can't seem to get NVL function working in my example below. If the location_id is NULL, as it is in the second row, I want to print 'N/A'.
CREATE TABLE departments (department_id, department_name, manager_id, location_id) AS
SELECT 100, 'Finance', 108, 1700 FROM DUAL UNION ALL
SELECT 120, 'Treasury', NULL, 1700 FROM DUAL;
BEGIN
FOR rec in (SELECT * from departments)
loop
dbms_output.put_line(rec.department_id||' '||rec.department_name||' '||NVL(rec.manager_id,'N/A')||' '||rec.location_id);
end loop;
END;
|
|
|
|
|