Q
Problem solve Get help with specific problems with your technologies, process and projects.

Update all docs in a view without using a loop

Is there any efficient way to update all of the columns in a view to a certain value without using a loop? Also, is there any way to retrieve only the record with the biggest value in a column? Like what the keyword MAX() does in an SQL statement.
I'm going to assume you mean all of the documents in a view, not all of the columns. Probably the most efficient way is to use LotusScript, and call the NotesViewEntryCollection.StampAll method. To update all the entries in a view, for instance, you might write:
Set view = db.GetView("viewname")
Set entrycoll = view.AllEntries
Call entrycoll.StampAll("fieldname", value) 

However, if you're updating more than one field, it probably is more efficient to iterate through the documents using view.GetFirstDocument and GetNextDocument. Use view.AutoUpdate to prevent the view index from being updated while you do your loop; if you delete documents, your loop should pre-fetch the next document at the top of the loop.

If the column is the first sorted column in the view, they you can easily find the largest one using view.GetFirstDocument or GetLastDocument (depending whether the sort is ascending or descending).

Otherwise, the quickest way to iterate through a view looking for the maximum value is to use an entrycoll variable, as shown above, and iterate thru the rows examining the ColumnValues property. Using a view that's already sorted is a lot faster, so it might be worth while to have a hidden view with this sort, if for no other reason.

Macro language does not offer an efficient way to do either of these tasks. While @Max(@DbColumn(...)) will work in some cases, you still have to retrieve all the data in a column, and there's a limit to how much data @DbColumn can return.

Do you have comments on this Ask the Expert question and response? Let us know.

Dig Deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close