I’m trying to traverse a view using NotesViewEntryCollection on a database view that has 16,000 records (they are small records containing 6 fields). I have a custom dbLookup script function that I’m using:
Function PerformDbLookupLSUnique( strServer As String, strDB As String ,strView As String, strKey As String , vFind As Variant ) As Variant
'==================================
’ PerformDbLookupLS function
'==================================
'Validate arguments
If Trim(strView) = "" Then Exit Function
If Trim(strKey) = "" Then Exit Function
If Trim(Cstr(vFind)) ="" Then Exit Function
Dim session As New notesSession
Dim dbTmp As notesDatabase
Dim viewTmp As NotesView
Dim LastViewEntryFound_Hold As String
Redim strReturnValuesArr( 0 ) As Variant
Msgbox Chr(10) & Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
Msgbox Chr(10) & Chr(10) & "Server [" & strServer & "] >> DB [" &strDB & "] >> VIEW [" & strView & "] >> KEY [" & strKey & "] >> FIND [" & vFind & "]"
Msgbox Chr(10) & Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
If strServer = "" Then
strServer = db.Server
End If
If strDB = "" Then
Set dbTmp = db
Else
Set dbTmp = session.GetDatabase(strServer, strDB)
End If
Set viewTmp = dbTmp.GetView(strView)
If viewTmp Is Nothing Then
Msgbox "DBLOOKUP : Attempt to lookup to a non-existent view " & strView & ", Server=" & dbTmp.Server & " NSF=" & db.FilePath
Exit Function
End If
’ keep the view order, use view entry collection
Dim vec As NotesViewEntryCollection
Set vec = viewTmp.GetAllEntriesByKey( strKey, True )
Dim ve As NotesViewEntry
If vec.Count <> 0 Then ' as Long as we have results...
Set ve = vec.GetFirstEntry()
Msgbox Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
Msgbox Chr(10) & vec.Count
Msgbox Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
Redim strReturnValuesArr( 0 To vec.Count+1 ) As Variant
Dim i As Long
Dim LUVal As String
i = -1
LastViewEntryFound_Hold = ""
Do While Not ve Is Nothing
LUVal = ve.ColumnValues(vFind-1)
If LastViewEntryFound_Hold <> LUVal Then
Msgbox Chr(10) & "ADD [" & i +1 & "] " & LUVal
LastViewEntryFound_Hold = ve.ColumnValues(vFind-1)
i = i + 1
strReturnValuesArr(i) =LUVal
Set ve = vec.GetNextEntry(ve)
Else
Msgbox Chr(10) & "SKIP [" & i+1 & "] " & LUVal
'skip to next entry
i = i + 1
Set ve = vec.GetNextEntry(ve)
End If
Loop
End If ' vec = 0
Msgbox Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
Msgbox Chr(10) & Ubound(strReturnValuesArr)
Msgbox Chr(10) & "---------------------------------------------------------------------------------------------------------------------------------------------"
PerformDbLookupLSUnique = strReturnValuesArr
End Function
When I call the function it iterates through about 15000 records and then causes the server to crash and restart. Am I doing something wrong? Anyone have any idea what could be causing the server to crash?
TIA for any help!
Wendall