25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Class Queries<br />

If the query takes runtime parameters, they appear on the method argument list after the query<br />

handle. For example, if the ByName query takes a name parameter, its signature is:<br />

ClassMethod ByNameExecute(ByRef qHandle As %Binary, Name As %String)<br />

As %Status<br />

{<br />

// query setup code here<br />

Quit $$$OK<br />

}<br />

8.2.2 The querynameFetch Method<br />

The querynameFetch method fetches a single row of data and formats it into $List format.<br />

(If it is unable to fetch a row, it returns "" in lieu of data.)<br />

If you create the query using the Wizard, it creates a method signature for you. The significant<br />

elements of this signature are:<br />

• The method's first argument, the qHandle variable, is of type %Binary, is defined in<br />

querynameExecute, and is passed by reference.<br />

• The method's second argument, the Row variable, is either a %List of column values<br />

representing the current row being returned and "" if no row is returned. It is passed by<br />

reference.<br />

• The method's third argument, the AtEnd variable, is of type %Integer and indicates that<br />

subsequent calls will not return a valid row. It is passed by reference.<br />

• The method returns status information in a variable of type %Status.<br />

8.2.2.1 The First Argument — The qHandle Variable<br />

The first argument of a querynameFetch method is of type %Binary, is called qHandle, and<br />

is passed by reference. It contains all information from querynameExecute needed by<br />

querynameFetch and passes information from both methods to querynameClose.<br />

8.2.2.2 The Second Argument — The Row Variable<br />

The second argument of a querynameFetch method is of type %List, is called Row, and is<br />

passed by reference. If the querynameFetch method can retrieve the next row's data, it sets<br />

the row data variable to a list containing the active row's data. The value of each field is a<br />

single element in that list. If no more rows can be returned (that is, the query has reached the<br />

end of the rows), then the variable is set to "".<br />

60 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!