Refresh view on server with agent

I’ve searched this form for an answer but have not yet been able to solve my problem. Here’s my situation (code below):

I have designed a search mechanism for users looking for a particular item. I am using @picklist to give the user a few ways to search for an item, order code, description, etc. Due to an endless influx of items and changed prices the database they are searching is rebuilt every evening . My process is that I delete all the existing documents in the database and then rebuild the databse with the agent below. Here’s the real problem - the first user to select a search after the database has been rebuilt thinks the app is broken becasue it takes a few minutes to rebuild the indices on each view. I need to be able to rebuild the views index without the user having to wait at all. Here’s the code, any help is greatly appreciated.

Thank you, Jeff

Option Public

Uselsx “*LSXODBC”

Dim db As notesdatabase

Dim uidoc As notesuidocument

Dim doc As notesdocument

Dim dept As String

Dim deptNum As String

Dim category As String

Dim categoryNum As String

Dim subCategory As String

Dim subCategoryNum As String

Dim segment As String

Dim segmentNum As String

Dim itemUPCNum As String

Dim itemDescr As String

Dim itemPack As String

Dim itemsize As String

Dim itemSizeDescr As String

Dim orderCode As String

Dim brandName As String

Sub Initialize

Dim Session As New NotesSession

Set db=Session.CurrentDataBase

Dim con As New ODBCConnection

Dim qry As New ODBCQuery

Dim rs As New ODBCResultSet

Dim view As NotesView

Dim founddoc As NotesDocument

Set view = db.GetView( "byUPC" )



Set qry.Connection = con

Set rs.Query = qry

con.SilentMode = True



rs.cachelimit=200

rs.fetchbatchsize=200



If Not(con.ConnectTo("backoffice066","bigy","bigy")) Then

	Msgbox "Unable to connect to database"

	Exit Sub

End If

qry.SQL = "select * from daily_backoffice_master_t"

rs.execute



Do

	rs.nextRow

	

	itemUPCNum = rs.GetValue("upc_no_check_digit_var") 

	Set founddoc = view.GetDocumentByKey(itemUPCNum)		

	

	If founddoc Is Nothing Then	

		dept = rs.getValue("dept_descr")

		category = rs.GetValue("category_descr")

		subCategory = rs.GetValue("sub_category_descr")

		segment = rs.GetValue("segment_descr")

		itemDescr = rs.GetValue("upc_long_descr")

’ itemPack = rs.GetValue(“pack_num”)

		itemSize = rs.GetValue("size_num")

		itemSizeDescr = rs.GetValue("size_descr")

		orderCode = rs.GetValue("item_num")

		braqndName = rs.GetValue("brand_descr")

		

		Set doc = New NotesDocument ( db )

		doc.Form = "itemSearch"

		doc.department = dept

		doc.category = category

		doc.subCategory = subCategory

		doc.segment = segment

		doc.description = itemDescr

		doc.pack = itemPack

		doc.sizeNum = itemSize

		doc.sizeDesc = itemSizeDescr

		doc.upc = itemUPCNum

		doc.orderCode = orderCode

		doc.brandName = brandName

		Call doc.Save( True, True )

		

	End If		

	

Loop Until rs.IsEndOfData	

rs.Close(DB_CLOSE)

con.Disconnect 



Forall AllView In db.Views

	Call AllView.refresh

End Forall



Set view = db.GetView("byOrderCode")

Call view.Refresh 

Set view = db.GetView("byUPC")

Call view.Refresh 

Set view = db.GetView("descriptionItems")

Call view.Refresh 

Set view = db.GetView("segmentItems")

Call view.Refresh 

End Sub

Subject: refresh view on server with agent

  • Doesn’t updall do this? Just schedule it to run nightly (it runs at 2am by default), and be sure your Agent finishes execution beforehand. Will that work?- I see you have View. refresh in there already, and that’s obviously not working. I think that just copies the view’s snapshot data into the notesView object … it doesn’t really “do” anything, index-wise.

  • Look up “Refreshing View Indexes” in Help. That refers to the properties box for View indexes, but may give you an idea on how to mitigate things.

  • Hope this helps…

Subject: RE: refresh view on server with agent

Thank you David. I re-scheculed some other agents and then scheduled this onen to run at 10 PM. This should allow updall to do it’s stuff.