文档介绍:BindSQL查询方法使用说明
使用说明
调用绑定变量查询接口使用说明。
声明BindSQL对象实例
编写标准绑定变量动态SQL。
顺序调用setValueList将参数,传入参数值,对应表名、列名。
表名与列名为SQL中参数对应列的表名与类型,SQL编写时对char类型的列使用trim()方法,则表名、列名传null即可。
setValueList提供两种构造函数方便调用者使用:
setValueList(String tValue,String tTableName,String tColName)
setValueList(double tValue,String tTableName,String tColName)
注:
若变量字段无对应表、列且变量的类型为varchar 则tTableName、tColName填null或“”
若变量字段无对应表、列且变量的类型为date 则tTableName、tColName填date
若变量字段无对应表、列且变量的类型为number 则tTableName、tColName填number
调用query(String tSQL)方法,传入编写好的动态SQL,得到SSRS容器。
该方法支持非绑定变量动态SQL查询,并返回SSRS,处理逻辑与ExeSQL类似。
实例
String tSQL = " Select '测试'||count(1) From lcpol l Where 1=1 "
+ " And = ? "
+ " And trim() = ? "
+ " And = ? "
+ " And = ? "
+ " And = ? "
+ " And = ? "
+ " And l. like ? "
+ " And (case ? when 1 then 1 end )=1 "
+ " And (case ? when ‘1’ then ‘1’ end )=1 "
;
BindSQL tBindSQL = new BindSQL();
("8632H00025520","lcpol","polno");
("8632H0002552",null,null);
(20000,"lcpol","amnt");
("12","lcpol","payintv");
("2002-6-27","lcpol","cvalidate");
("00601000","lcpol","riskcode");
("8632%","","");
("1","number","number");
("1","","");