要传入多个值不能那么写 declare dno varchar2(1000):='7369,7499'; mycur sys_refcursor; emprow scott.emp%rowtype; begin open mycur for 'select * from scott.emp t where t.empno in ('||dno||')'; loop fetch mycur into emprow; exit when mycur%notfound; dbms_output.put_line('name: '||emprow.ename||'salary: '||emprow.sal); end loop; close mycur; end;
declare
dno varchar2(1000):='7369,7499';
mycur sys_refcursor;
emprow scott.emp%rowtype;
begin
open mycur for 'select * from scott.emp t where t.empno in ('||dno||')';
loop
fetch mycur into emprow;
exit when mycur%notfound;
dbms_output.put_line('name: '||emprow.ename||'salary: '||emprow.sal);
end loop;
close mycur;
end;