DECLARE
vr_employee employees%ROWTYPE;
z_emp_id NUMBER:=&employee_id;
BEGIN
SELECT *
INTO vr_employee
FROM employees
WHERE employee_id = z_emp_id;
dbms_output.Put_line (vr_employee.first_name
||' '
||vr_employee.last_name
||' has an ID of '||z_emp_id);
EXCEPTION
WHEN no_data_found THEN
Raise_application_error(-20001, 'The Employee '
|| 'is not in the database');
END;
/
Sample Output:
SQL> /
Enter value for employee_id: 159
old 3: z_emp_id NUMBER:=&employee_id;
new 3: z_emp_id NUMBER:=159;
Lindsey Smith has an ID of 159
PL/SQL procedure successfully completed.
SQL> /
Enter value for employee_id: 459
old 3: z_emp_id NUMBER:=&employee_id;
new 3: z_emp_id NUMBER:=459;
DECLARE
*
ERROR at line 1:
ORA-20001: The Employee is not in the database
ORA-06512: at line 16
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer