birt用script实现模糊查询(条件不带%百分号)

birtscript实现模糊查询(条件不带%百分号)

//sql server

var stationName = params["stationName"]; var year = params["year"];

//此处的queryText默认是DataSet中的Query中的String,当Property Binding中有String时优先使用. //queryText = "select * from pems.dbo.warning";

if(stationName != "") {

 queryText += " where stationName = '" + stationName + "'";

 if(year != null && year != "") {   queryText += " and startTime like '%" + year + "%'";  } } else {    if(year != null && year != "") {   queryText += " where startTime like '%" + year + "%'";  } }

//mysql var stationName = params["stationName"]; var year = params["year"];

//queryText = "select * from warning";

if(stationName != "") {

 queryText += " where stationName = '" + stationName + "'";

 if(year != null && year != "") {   queryText += " and startTime like '" + year + "%'";  } } else {    if(year != null && year != "") {   queryText += " where startTime like '" + year + "%'";  } }

注意:

其中的null,其实不对应于参数里的Null Value的,这个问题我没找到,到底Null Value在script中接收到后是一个什么值还不知道.null这个值是我自己随意加的.if语句可以根据你的需要决定.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章