帮忙简化

rocklicong 2011-06-13 11:36:19
string l_cb1,l_cb2,l_cb3,l_cb4,l_sql,sqlstring
l_cb1=trim(string(sle_1.text));
l_cb2=trim(string(sle_2.text));
l_cb3=trim(string(sle_3.text));
l_cb4=trim(string(sle_4.text));

if l_cb1='' or isnull(l_cb1) then
l_cb1=''
else
l_cb1=" and order_custom ="+l_cb1
end if

if l_cb2='' or isnull(l_cb2) then
l_cb2=''
else
l_cb2=" and order_id like "+"'%"+l_cb2+"%'"
end if

if l_cb3='' or isnull(l_cb3) then
l_cb3=''
else
l_cb3=" and order_id like "+"'%"+l_cb3+"%'"
end if

if l_cb4='' or isnull(l_cb3) then
l_cb4=''
else
l_cb4=" and order_id like "+"'%"+l_cb4+"%'"
end if


l_sql= " where 1=1 " +l_cb1+l_cb2+l_cb3+l_cb4
...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
路人甲cw 2011-06-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yyoinge 的回复:]

C/C++ code
int i
string ls_col1[] = {"order_custom = ", "order_id like '%", "order_id like '%", "order_id like '%"}
string ls_col2[] = {"", "%'", "%'", "%'"}
string ls_data[]
string l_sql= " where 1……
[/Quote]
支持!!!
WorldMobile 2011-06-13
  • 打赏
  • 举报
回复


if l_cb3='' or isnull(l_cb3) then
l_cb3=''
else
l_cb3=" and order_id like "+"'%"+l_cb3+"%'"
end if

写成函数,然后调用,程序就可以简化了
yyoinge 2011-06-13
  • 打赏
  • 举报
回复
int i
string ls_col1[] = {"order_custom = ", "order_id like '%", "order_id like '%", "order_id like '%"}
string ls_col2[] = {"", "%'", "%'", "%'"}
string ls_data[]
string l_sql= " where 1=1 "
ls_data = {sle_1.text,sle_2.text,sle_3.text,sle_4.text}
for i = 1 to upperbound(ls_col1)
if not(ls_data[i] = '' or isnull(ls_data[i])) then l_sql += " and " + ls_col1[i] + ls_data[i] + ls_col2[i]
next

1,078

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧