在我们给empid作为参数时编写一个程序,那么它应该使用emp deptno并显示这些deptno emp名称
答案 0 :(得分:0)
有多种选择;这是其中之一。
SQL> set serveroutput on
SQL>
SQL> create or replace procedure p_emp (par_empno in emp.empno%type) is
2 l_row emp%rowtype;
3 begin
4 select *
5 into l_row
6 from emp
7 where empno = par_empno;
8
9 dbms_output.put_line(l_row.deptno ||' '|| l_row.ename);
10 exception
11 when no_data_found then
12 dbms_output.put_line('No such employee');
13 end;
14 /
Procedure created.
SQL> exec p_emp(7788);
20 SCOTT
PL/SQL procedure successfully completed.
SQL> exec p_emp(-1);
No such employee
PL/SQL procedure successfully completed.
SQL>