Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Class Queries<br />
8.1 Query Basics<br />
The process for creating and using a class query is:<br />
1. Define the query. The simplest way to do this is using the New Query Wizard in the<br />
<strong>Caché</strong> Studio.<br />
2. Invoke the query. This can be using the %New method of the %Library.ResultSet class<br />
within server-based methods; using the Java or ActiveX result set classes that are part of<br />
the <strong>Caché</strong> Java and ActiveX bindings, respectively; or as a OBDC or JDBC stored procedure.<br />
3. Once the query has returned a %Library.ResultSet object (often known as a result set),<br />
fetch data from it. (Further information on the result set processing is available in the<br />
“Dynamic SQL” chapter of the <strong>Using</strong> <strong>Caché</strong> SQL guide.<br />
4. When processing is complete, close the result set.<br />
8.1.1 The Structure of a Class Query<br />
The simplest query is of type %SQLQuery and simply contains an SQL SELECT statement.<br />
Such a query performs all processing for the application. It is of the form:<br />
Query QueryName(Parameter As %String) As %SQLQuery<br />
{<br />
SELECT MyProperty, MyOtherProperty FROM MyClass<br />
WHERE (MyProperty = "Hello" AND MyOtherProperty = :Parameter)<br />
ORDER BY MyProperty<br />
}<br />
You can also create a query of type %Query, which allows the application to perform its own<br />
custom processing. Such a query is of the form:<br />
8.1.2 Query Keywords<br />
You can modify a query definition through the use of one or more query keywords. Each<br />
keyword is optional and has a default value if not explicitly specified. The major query keywords<br />
are:<br />
Description<br />
Provides an optional description of the query; <strong>Caché</strong> does not use this description.<br />
By default, queries have no description.<br />
56 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>