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.
For example, the following returns a set of all the object ID values for the Sample.Person<br />
class:<br />
Set rset = ##class(%ResultSet).%New("Sample.Person:Extent")<br />
Do rset.Execute()<br />
While (rset.Next()) {<br />
Write rset.Data("ID"),!<br />
}<br />
The Sample.Person extent include all instances of Sample.Person as well as its subclass<br />
Sample.Employee. If you want to only see the instances of Sample.Employee (and its subclasses)<br />
then use its Extent query:<br />
Set rset = ##class(%ResultSet).%New("Sample.Employee:Extent")<br />
Do rset.Execute()<br />
While (rset.Next()) {<br />
Write rset.Data("ID"),!<br />
}<br />
The Extent query is equivalent to the following SQL query:<br />
SELECT %ID FROM Sample.Person<br />
Storage Definitions and Storage Classes<br />
Note that you cannot rely on the order in which ID values are returned using either of these<br />
method: <strong>Caché</strong> may determine that it is more efficient to use an index that is ordered using<br />
some other property value to satisfy this request. You can add an ORDER BY %ID clause<br />
to your SQL query if you need to.<br />
12.4 Storage Definitions and Storage Classes<br />
The %Persistent class provides the high-level interface for storing and retrieving objects in<br />
the database. The actual work of storing and loading objects is performed by what is called<br />
a storage class.<br />
Every persistent (and serial) object uses a storage class to generate the actual methods used<br />
to store, load, and delete objects in a database. These internal methods are referred to the<br />
Storage Interface. The Storage Interface includes methods such as %LoadData, %SaveData,<br />
and %DeleteData. Applications never call these methods directly, instead they are called at<br />
the appropriate time by the methods of the Persistence Interface (such as %OpenId and<br />
%Save).<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 109