oracle过程防止sql注入,oracle存储过程防止sql注入的有关问题。

SQL codeCREATE OR REPLACE function certificatefunction1

(

projectstate in int,

projectname in varchar,

startDateMin in varchar,

startDateMax in varchar,

endDateMin in varchar,

endDateMax in varchar,

certificateType in int,

versions in varchar

) return sys_refcursor

as

cursor1 sys_refcursor;

projectname_temp varchar(50);

sqlstr varchar(2000);

begin

sqlstr := sqlstr || ' select pp.profile_Id,pp.name,pp.version,pp.start_Date,pp.end_Date,pci.certificate_Type ';

sqlstr := sqlstr || ' from Project_Profile pp,Project_Certificate_Info pci ';

sqlstr := sqlstr || ' where pp.profile_Id = pci.profile_Id ';

sqlstr := sqlstr || ' and pp.status != ' || projectstate;

if projectname is not null then

select replace(projectname,'''','') into projectname_temp from dual;

sqlstr := sqlstr || ' and pp.name like ''%' || projectname_temp || '%''';

end if;

if startDateMin is not null then

sqlstr := sqlstr || ' and pp.start_date >= to_date(''' || startDateMin || ''',''yyyy-mm-dd'')';

end if;

if startDateMax is not null then

sqlstr := sqlstr || ' and pp.start_date < to_date(''' || startDateMax || ''',''yyyy-mm-dd'')';

end if;

if endDateMin is not null then

sqlstr := sqlstr || ' and pp.end_date >= to_date(''' || endDateMin || ''',''yyyy-mm-dd'')';

end if;

if endDateMax is not null then

sqlstr := sqlstr || ' and pp.end_date <= to_date(''' || endDateMax || ''',''yyyy-mm-dd'')';

end if;

if certificateType != -1 then

sqlstr := sqlstr || ' and pci.certificate_Type = ' || certificateType;

end if;

if versions is not null then

sqlstr := sqlstr || ' and pp.version like ''%' || versions || '%''';

end if;

sqlstr := sqlstr || ' order by pp.profile_Id desc ';

open cursor1 for sqlstr;

return cursor1;

end certificatefunction1;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值