如何缩短查询时间?

bmhippo 2003-09-12 12:28:03
我们公司notes里有个领取物品的功能:
先填领物品的单子,这时候需要填单子上的编号,在编号域的EXITING事件中,进行编号查询,以避免编号重复,软件公司给我们写的是这样的:
Sub Exiting(Source As Field)
Dim session As New notessession
Dim workspace As New notesuiworkspace
Dim db As notesdatabase
Dim dc As notesdocumentcollection
Dim doc As notesdocument
Dim uidoc As notesuidocument
Dim workcard As Variant
Dim workcard1 As Variant

Set db=session.currentdatabase
Set dc=db.alldocuments
Set uidoc=workspace.currentdocument
workcard=uidoc.fieldgettext("lingliao_code")

If uidoc.isnewdoc Then
If workcard<>"" Then
For i=1 To dc.count
Set doc=dc.getnthdocument(i)
workcard1=doc.getitemvalue("lingliao_code")

If workcard=workcard1(0) Then
Messagebox "此编号已存在,请确认后重新输入!"
Call uidoc.fieldclear("lingliao_code")
Call uidoc.gotofield("lingliao_code")
Exit For
End If
Next
End If
End If
End Sub

这样写虽然可以,但随着数据库里记录的增多,目前速度已经慢的比较夸张了,我填完编号,可以等5分钟以上,请问,有什么更好的方法可以缩短查询时间么?谢谢!
...全文
82 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
bmhippo 2003-09-12
  • 打赏
  • 举报
回复
因为我们领物品的纸单子各部门都有,所以编号不可能按序号,因此最大值这个不可行,能否把“1、锁定查询范围 如在某个视图中找 2、设定返回记录条数”说的详细点,具体点,因为我不懂NOTES
gjd111686 2003-09-12
  • 打赏
  • 举报
回复
记录的编号可以在另一个视图中,视图公式提取最大值,此视图只有一个文档.
每次操作完成同时更新此文档就可以了
cnhxjtoa 2003-09-12
  • 打赏
  • 举报
回复
1、锁定查询范围
如在某个视图中找
2、设定返回记录条数
亓锋 2003-09-12
  • 打赏
  • 举报
回复
if uidoc.isnewdoc then
set dc = db.search(|form="领料单"&@trim(@lowsercase(bianhao))="|+trim(lcase(uidoc.fieldgettext("bianhao")))+|"|,nothing,1)
if dc.count>0 then
msgbox "重复"
end if
else

set dc = db.search(|form="领料单"&@trim(@lowsercase(bianhao))="|+trim(lcase(uidoc.fieldgettext("bianhao")))+|"&@text(@documentuniqueid)!="|+uidoc.document.universalid+|"|,nothing,1)
if dc.count>0 then
msgbox "重复"
end if

endif
eq9684 2003-09-12
  • 打赏
  • 举报
回复
做一个视图用编号排序,
然后用getfirstdocumentbykey,返回文档就是已存在,返回nothing就是不存在。
ygtel 2003-09-12
  • 打赏
  • 举报
回复
做一个试图只纪录编号
用你新添的编号为条件搜索,查到就“此编号已存在,请确认后重新输入!”

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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