日期:2014-05-17 浏览次数:21311 次
SELECT * FROM emp, dept WHERE emp.empno = dept.deptno;
------解决方案--------------------
begin for c_emp in(SELECT e.* FROM emp e, dept d WHERE e.deptno =d.deptno and d.deptno=&deptno) loop dbms_output.put_line('员工ID:'||c_emp.empno|| ' 员工姓名:'|| c_emp.ename ); end loop; emd;
------解决方案--------------------
1.plsql中处理集合,都是使用游标来进行处理。
括号中的sql,可以看做plsql中的隐式游标。
------解决方案--------------------
一下是使用显示游标做法:
create or replace procedure SPTEST(p_deptno in number) as
cursor c_test is SELECT e.empno, e.ename FROM emp e, dept d WHERE e.deptno = d.deptno and d.deptno=p_deptno;
v_id emp.empno%type;
v_name emp.ename%type;
v_resutl varchar2(1000);
begin
open c_test;
fetch c_test into v_id, v_name;
while c_type%found loop
dbms_output.put_line('员工ID:' || v_id || ' 员工姓名:'|| v_name);
fetch c_test into v_id, v_name;
end loop;
close c_tesgt;
end SPTEST;
------解决方案--------------------
close c_tesgt;
写错了
close_c_test;