Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section

Query Definitions

Describes the structure of a query definition.


A class query is a named query that is part of a class structure and that can be accessed via dynamic SQL.

You can define class queries within any class; there is no requirement to contain them within persistent classes.


A query definition has the following structure:

/// description Query name(formal_spec) As classname [ keyword_list ]  { implementation }


  • description (optional) is intended for display in the Class Reference. The description is blank by default. See “Creating Class Documentation” in Using Caché Objects.

  • name (required) is the name of the query. This must be a valid class member name, and must not conflict with any other class member names.

  • formal_spec (optional) specifies the list of arguments that are passed to the query.

    Specifically, this is the list of arguments that are passed to the query via the Execute() method of the associated query class.

    See the comments for formal_spec in “Method Definitions.”

  • classname (required) specifies the query class used by this query.

    This is typically %SQLQuery for SQL-based queries and %Query for custom queries. See “Class Queries” in Using Caché Objects.

  • keyword_list (optional) is a comma-separated list of keywords that further define the query.

    See the section “Query Keywords.”

    If this list is omitted, also omit the square brackets.

  • implementation (optional) is zero or more lines of code that define the query.

See Also

FeedbackOpens in a new window