Execute method (NotesDominoQuery - LotusScript)

Executes a query string passed in according to set parameters and returns named results in a database where they can be accessed again more quickly. For reuse of complex queries, this saves significant processing time.

Defined in



Set doccol = NotesDominoQuery.Execute(Query$, Optional String ResultName, Optional Boolean Replace, Optional Long ExpireHours)



String. A query in DQL syntax.


String. The name to use to save a DocumentCollection in the database for future DQL reference. The name is case-sensitive.


Boolean. If a saved DocumentCollection with ResultName exists, overwrite it. If not set, an error is thrown indicating a conflict.


Long. The amount of time, in hours, to retain the a DocumentCollection saved for future DQL reference. Default is 24 hours if omitted.
Note: The Domino updall command used with the -j option provides options for managing named results. For more information, see the Domino documentation.
Note: In preparation for a future refresh capability, if your query contains substitution variables (e.g. &value) then you cannot save the results.

Return value



Dim Query As String
Dim db As NotesDatabase 
Dim TheQuery As NotesDominoQuery
Dim doccol As NotesDocumentCollection
Dim ResultName As String
Dim ExpireHours As Long
Dim Session As New NotesSession
Set db = Session.getdatabase("", "my.nsf")
Set TheQuery = db.Createdominoquery()
Query$ = "firstname = 'Annabelle' and lastname = 'Stevens' and 'Personview'.dept = 'Sales'"
ResultName = "MySavedResults"
ExpireHours = 72
' Runs the query, returns results in doccol and saves them for future reference (DQL in clause) 
' in "MySavedResults", a named set of documents that will be deleted by updall in 72 hours
Set doccol = TheQuery.Execute(Query$, ResultName, ExpireHours)

Language cross-reference

execute method (DominoQuery - Java)