execute method (DominoQuery - Java)

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

DominoQuery

Syntax

DocumentCollection execute (String query) throws NotesException

DocumentCollection execute(String query, String resultname) throws NotesException

DocumentCollection execute(String query, String resultname, boolean replace, int expirehours) throws NotesException

Parameters

String query

A string containing a DQL query.

String resultname

An optional name to use to save the DocumentCollection in a database for future DQL reference. The name is case-insensitive.

boolean replace

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

String int expirehours

The amount of time, in hours, to retain a saved DocumentCollection 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.

Returned value

DocumentCollection

Usage

Returns results from a DQL query. The query is performed and a DocumentCollection is returned for use in all legal contexts. Some runtime errors are also possible and if they occur, their text will appear in the NotesException that is returned.

Note: In preparation for a future refresh capability, if your query contains substitution variables (e.g. ?value1) then you cannot save the results.
Note: Saving result sets is only supported locally, not on remote databases. If you try to save a result set when querying on a remote database, an invalid arguments error is given.

Example

Database db = session.getDatabase("myServerName", "my.nsf");
DominoQuery dq = db.createDominoQuery();
String queryStr = "firstname = 'Annabelle' and lastname = 'Stevens' and 'Personview'.dept = 'Sales'";
String resultName = "MySavedResults";
int expireHours = 72;
boolean replace = false;
// 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
DocumentCollection doccol = dq.execute(queryStr, resultName, replace, expireHours);

Language cross-reference

Execute method (NotesDominoQuery - LotusScript)