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.
8<br />
Class Queries<br />
Class queries provides a tool to look up instances of a class that meet specified criteria. They<br />
allow you to create named SQL statements that are part of a class structure so that applications<br />
can have pre-defined lookups. For example, you can look up instances by some property,<br />
such as by name, or provide a list of instances that meet a particular set of conditions, such<br />
as all the flights from Paris to Madrid.<br />
By creating a class query, you can avoid having to look up a particular object by its internal<br />
ID. Instead, you can create a query that looks based on any class properties that you want.<br />
These can even be specified from user input at runtime.<br />
A class query can be either in SQL or <strong>Caché</strong> ObjectScript. To create a query, use the <strong>Caché</strong><br />
Studio and create one either by hand or using the New Query Wizard.<br />
Class queries are designed for transparent use with the relational aspect of <strong>Caché</strong> classes. As<br />
stated, they use SQL syntax. When the application invokes the query, it returns values in a<br />
%Library.ResultSet object, which provides robust interface for processing data.<br />
Class queries provide logical comparisons for data values. You can compare whether the<br />
value is greater than, equal to, or less than a certain value and include only the objects with<br />
values that pass the specified test. You can also compare whether the value starts with a certain<br />
string and include these objects in the result set. A query can also perform multiple comparisons.<br />
Because the comparisons support any combination of nested AND and OR operators,<br />
you can require that an object meets one, some, or all of them in order to be added to the<br />
result set.<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 55