日期:2014-05-17  浏览次数:20832 次

Oracle 动态sql 参数问题

  PROCEDURE palinW(v_para varchar2, v_cursor   out RECORD_TYPE) is
begin
vSql := 'select id;
    for vL in cursorCol loop
      vSql := vSql || ',' || 'sum(decode(code,''' || vL.code ||
              ''', 1,0)) as "' || vL.code||'"';
    end loop;
    vSql := vSql || ' from imep_customercomplaint_view where 参数='''||v_para||''' group by id';
open cursor  for vSql ;
end;

如上:where 参数='''||v_para||''' 
这样会存在被注入的危险,我想使用参数,而不是使用||链接字符串拼sql,orace能不能再拼接的字符串中使用参数。比如 vSql := vSql || ' from imep_customercomplaint_view where 参数=@参数 group by id';

这个的时候吧@参数传进去。。。。不知道oracle 是否有这样类似的功能!!!!!!!!!!!!!!!!!!!!!!

------解决方案--------------------
看你这小部分代码,带参数的游标可破.

看楼下都说些什么.
------解决方案--------------------
都看不懂
应该加强学习了
------解决方案--------------------
语句里面,使用绑定变量

where 参数 = :p1 

执行时,绑定值

open cursor  for vSql using v_para;


------解决方案--------------------
亂七八糟 看不懂