create or replace procedure find_emp(p_empName char) as r_emp tmp1%rowtype; type c_type is ref cursor; c1 c_type; begin open c1 for ' select * from tmp1 where id =:1' using p_empName; loop fetch c1 into r_emp; exit when c1%notfound; dbms_output.put_line('员工为:'); dbms_output.put_line('ID为'||p_empName||' 其姓名为:'||r_emp.id); end loop; close c1; end find_emp;可以阿,用using可以传入参数进去,上面是我修改的语句 你的语句中:dbms_output.put_line('ID为'to_char(r_emp)||' 其姓名为:'||r_emp.name); 有错'ID为' 后面要加||
sqlstr VARCHAR2(1000);
BEGIN
sqlstr:='select .................................';
OPEN cur_result_out FOR sqlstr USING vTarget_in;
这种形式也报同样的错误.
我是想做一个动态查询,通过传入参数然后返回结果集.在sql server中可以通过.是不是oracle对字符处理有什么特别的要求.
r_emp tmp1%rowtype;
type c_type is ref cursor;
c1 c_type;
begin
open c1 for '
select * from tmp1
where id =:1'
using p_empName;
loop
fetch c1 into r_emp;
exit when c1%notfound;
dbms_output.put_line('员工为:');
dbms_output.put_line('ID为'||p_empName||' 其姓名为:'||r_emp.id);
end loop;
close c1;
end find_emp;可以阿,用using可以传入参数进去,上面是我修改的语句
你的语句中:dbms_output.put_line('ID为'to_char(r_emp)||' 其姓名为:'||r_emp.name);
有错'ID为' 后面要加||