Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The data in Row is the result of executing the query code. Usually, the data in Row is a simple<br />
transformation of a row of the result set. This, however, need not be the case. The code may<br />
perform arbitrary calculations on the result set data and return what it produces in Row. For<br />
example, a call to querynameFetch might return only the first 50 rows of the result set and<br />
convert the names to asterisks for privacy.<br />
8.2.2.3 The Third Argument — The AtEnd Variable<br />
The third argument of a querynameFetch method is of type %Integer, is called AtEnd, and<br />
is passed by reference. If AtEnd equals 1, further calls to querynameFetch will not return<br />
valid rows.<br />
For example, if the ByNameFetch method uses embedded SQL to retrieve data, SQLCODE=100<br />
indicates that no more data is available:<br />
If SQLCODE = 100<br />
{<br />
Set Row = ""<br />
Set AtEnd = 1<br />
}<br />
This is the simplest case, in which reaching the end of the result set causes the method to set<br />
AtEnd to 1. The method's code could alternately perform any processing that its application<br />
requires.<br />
8.2.2.4 Content of the querynameFetch Method<br />
The method code begins by performing tests to determine if it should return any more results.<br />
Usually, if the next fetch should occur, it uses the class query's ROWSPEC specification to<br />
perform processing; it then creates a %List object that is placed in the Row variable. If the<br />
return code from the result set indicates that no more fetches should occur, set the value of<br />
Row to ""; also, set the value of AtEnd to 1.<br />
8.2.2.5 A Sample querynameFetch Signature<br />
Continuing the ByName example, the ByNameFetch method would have the following signature:<br />
ClassMethod ByNameFetch(ByRef qHandle As %Binary,<br />
ByRef Row As %List, ByRef AtEnd As %Integer = 0)<br />
As %Status [ PlaceAfter = ByNameExecute ]<br />
{<br />
// Method code<br />
}<br />
User-Written Class Queries<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 61