This repository was archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPLSQL Exception Handling.sql
More file actions
58 lines (55 loc) · 1.67 KB
/
PLSQL Exception Handling.sql
File metadata and controls
58 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Formatted on 27/Oct/21 12:21:41 PM (QP5 v5.287) */
DECLARE
v_variable VARCHAR2 (100);
v_eid employees.employee_id%TYPE;
v_dptid departments.department_id%TYPE := 90;
BEGIN
SELECT e.last_name, e.department_id, e.employee_id
INTO v_variable, v_dptid, v_eid
FROM employees e, departments d
WHERE d.department_id = e.department_id
AND e.department_id = v_dptid
AND e.employee_id = v_eid;
DBMS_OUTPUT.put_line (
'Empolyee ID: '
|| v_eid
|| ' And The Name Of The Employee Is: '
|| v_variable
|| ' Department ID Is: '
|| v_dptid);
EXCEPTION
WHEN TOO_MANY_ROWS
THEN
v_eid := 101;
DBMS_OUTPUT.put_line (
'Too many rows found that why we take on specific employee id');
DBMS_OUTPUT.put_line (
'Empolyee ID: '
|| v_eid
|| ' And The Name Of The Employee Is: '
|| v_variable
|| ' Department ID Is: '
|| v_dptid);
WHEN NO_DATA_FOUND
THEN
v_eid := 101;
v_dptid := 90;
SELECT e.last_name, e.department_id, e.employee_id
INTO v_variable, v_dptid, v_eid
FROM employees e, departments d
WHERE d.department_id = e.department_id
AND e.department_id = v_dptid
AND e.employee_id = v_eid;
DBMS_OUTPUT.put_line ('No citizen detail found');
DBMS_OUTPUT.put_line (
'Empolyee ID: '
|| v_eid
|| ' And The Name Of The Employee Is: '
|| v_variable
|| ' Department ID Is: '
|| v_dptid);
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Empolyee ID: ' || v_eid || ' ' || v_variable);
END;
/