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
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.
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.
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);