SQL> CREATE OR REPLACE PROCEDURE displayEmp
2 (p_empno IN NUMBER)
3 IS
4 TYPE emp_record_type is record
5 (empno emp.empno%type,
6 ename emp.ename%type);
7 emp_record emp_record_type;
8 BEGIN
9 SELECT empno, ename
10 INTO emp_record.empno, emp_record.ename
11 FROM emp
12 WHERE empno = p_empno;
13 DBMS_OUTPUT.PUT_LINE(emp_record.empno || ':' || emp_record.ename );
14 EXCEPTION
15 WHEN NO_DATA_FOUND THEN
16 DBMS_OUTPUT.PUT_LINE('no data...');
17 WHEN TOO_MANY_ROWS THEN
18 DBMS_OUTPUT.PUT_LINE('to many rows...');
19 END displayEmp;
20 /
Procedure created.
SQL> exec displayEmp(7369);
7369:SMITH
PL/SQL procedure successfully completed.
SQL> exec displayEmp(3333);
no data...
PL/SQL procedure successfully completed.
댓글 없음:
댓글 쓰기