Home > Ask the Domino Experts > Domino Development Questions & Answers > Update all docs in a view without using a loop
Ask The Domino Expert: Questions & Answers
EMAIL THIS

Update all docs in a view without using a loop

Andre Guirard EXPERT RESPONSE FROM: Andre Guirard

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 09 December 2004
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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Domino Development
Can I create and copy Microsoft Excel spreadsheets with LotusScript?
'Illegal circular use: Audit Trail' error when opening Lotus Notes docs
How to make computed fields recalculate
Sending and logging faxes from Lotus Notes and Domino
Accessing documents in a Lotus Notes database
Adding an action to the Lotus Notes right-click menu
Writing temporary text files that email as attachments
Trapping the on-click event of a radio button
Copying a form object using LotusScript
Connecting to a remote DB2 server with LEI

LotusScript
LotusScript agent parses ACL to Microsoft Notepad
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts