求大神帮助,我数据窗口retrieve的问题

阿鸣repairman 2016-03-31 09:57:16
我在数据窗口里设置了参数where条件做retrieve检索,如图,但是我的数据里如果没有存出生日期,输入条件检索后值显示有出生日期的数据,如果把第二个and改成or 输入条件姓名,人员代码,生日范围,检索后就会出现两个种数据,一种是满足代码姓名的,一种是满足出生日期范围的,应该怎么改?
...全文
334 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_1919561306 2016-04-24
  • 打赏
  • 举报
回复
where (code like :as_code ) and (name like :as_name ) and ((birthday between :date1 and :date2) or (birthday is null))
deerlion 2016-04-23
  • 打赏
  • 举报
回复
想实现的是什么? 第一种方法实现的是按代码,姓名查询的内容 第二种方法实现是大于某个日期的所有人和按代码,姓名以及小于某个日期的合集
WorldMobile 2016-04-05
  • 打赏
  • 举报
回复
不用改查询条件,用and是对的,看了一下你的代码,如果code和name都为空的话,是按出生日期检索的,如果输入了name,未输入其它内容的话,是按name来检索的,代码没看出什么 问题
阿鸣repairman 2016-03-31
  • 打赏
  • 举报
回复
我写了一个定义函数用来检索
String ls_code, ls_name
Date ld_birthday, ld_birthday1
Int li_count

dw_empwhere.AcceptText()

ls_code = dw_empwhere.Object.emp_code[1]
ls_name = dw_empwhere.Object.emp_name[1]
ld_birthday = dw_empwhere.Object.emp_birthday[1]
ld_birthday1 = dw_empwhere.Object.emp_birthday1[1]

If ls_code = "" Or IsNull(ls_code) Then
	ls_code = "%"
Else
	ls_code = "%" + ls_code + "%"
End If

If ls_name = "" Or IsNull(ls_name) Then
	ls_name = "%"
Else
	ls_name = "%" + ls_name + "%"
End If

If IsNull(ld_birthday) Or String(ld_birthday, "yyyy-mm-dd") < "1900-01-01" Then
	ld_birthday = Date("1900-01-01")
End If

If IsNull(ld_birthday1) Or String(ld_birthday1, "yyyy-mm-dd") > "2399-12-31" Then
	ld_birthday1 = Date("2399-12-31")
End If

li_count = dw_emplist.Retrieve(ls_code, ls_name, ld_birthday, ld_birthday1)

If li_count > 0 Then 
	dw_emplist.ScrollToRow(1)
	dw_emplist.selectrow(0,false)
	dw_emplist.selectrow(1,true)
   dw_emplist.Event rowfocuschanged(1)
End If

Return 1
zhangyangziwo 2016-03-31
  • 打赏
  • 举报
回复
没看明白你要实现什么目标 想要两个条件都满足的就需要用 and ,两个条件满足一个就可,就用or 这是数据库脚本的语法

611

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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