更高效的通用查询方法

zpy_01 zpy_01 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
因为文档少,所以采用了以下方法:
Function GetDocUnidByOneStrField(ViewName As String,FieldName As String,FieldVal As String) As String
Dim session As NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim TmpStr As Variant

Set session= New NotesSession
Set db = session.CurrentDatabase '(session、db是全局的,此处为示例代码)
Set view = db.GetView( ViewName )
GetDocUnidByOneField=""
Set doc = view.GetFirstDocument()

While Not(doc Is Nothing)
TmpStr = doc.GetItemValue("""" & FieldName & """")(0)
If FieldVal =TmpStr Then
GetDocUnidByOneField=doc.UniversalID
Goto last
End If

Set doc = view.GetNextDocument(doc)
Wend
last:
Set view = Nothing
Set doc = Nothing
End Function

说明:符合域值条件的文档只取第一条

问题:
1:TmpStr返回为空,但对应文档中的数据是确实存在的。
2:效率低下,有没有更好的办法?不采用GetDocumentByKey原因是因为域太多,不可能每个都建索引。

谢谢!
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
zpy_01
消息协作 536 成员 39,094 内容