NotesViewEntryCollection limit?

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

Subject: NotesViewEntryCollection limit???

I don’t know what is causing the crash, but I don’t think it is because of a limit to the number of entries in a notesviewentry collection. I just looped through 111,000+ with a LotusScript agent this afternoon without problem. It took a while to get the collection, but once I had it I was fine.

Subject: NotesViewEntryCollection limit???

I suspect that your problem is likely in this statement:

Redim strReturnValuesArr( 0 To vec.Count+1 ) As Variant

I don’t quite follow the logic of what you are doing - it seems like you are skipping some view entries while adding others into the array. You use i as the index into the array and you seem to increment i even if you are skipping.

Perhaps the number of elements in your array are greater than can be indexed?

See http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/a16b1221784aedb1852571a9004cc013?OpenDocument

Do yourself a favor and print the value of vec.Count+1 and then the value of i at the line

strReturnValuesArr(i) =LUVal

I suspect that you are creating a sparsely populated array.

Subject: RE: NotesViewEntryCollection limit???

Thanks for the response. I know what you mean about the null array entries. I was doing this just to make sure that the number of entries in the array matched the number of elements. I was then fulltrimming the array to remove the null entries … alot of extra work that would have been removed when I got this piece of code working.

I stripped out the array portion and it seems to run through the VEC without a problem. So rather than create an array and process it, I’m just doing a direct process as I loop through the VEC.