Using the Function DECODE
DECLARE
the_manager VARCHAR2(40);
NAME employees.last_name%TYPE;
BEGIN
-- NULL is a valid argument to DECODE. In this case, manager_id is null
-- and the DECODE function returns 'nobody'.
SELECT DECODE(manager_id,NULL,'nobody',
'somebody'),
last_name
INTO the_manager,NAME
FROM employees
WHERE employee_id = 100;
dbms_output.Put_line(NAME
||' is managed by '
||the_manager);
END;
/
0 comments:
Post a Comment