4. ZOOM::resultSet

A ZOOM::resultSet object represents a set of records identified by a query that has been executed against a particular connection. The sole purpose of both connection and query objects is that they can be used to create new resultSets - that is, to perform a search on the server on the remote end of the connection.

The class has this declaration:

    class resultSet {
    public:
      resultSet (connection &c, const query &q);
      ~resultSet ();
      const char *option (const char *key) const;
      const char *option (const char *key, const char *val);
      size_t size () const;
      const record *getRecord (size_t i) const;
    };
   

New resultSets are created by the constructor, which is passed a connection, indicating the server on which the search is to be performed, and a query, indicating what search to perform. If the search fails - for example, because the query uses attributes that the server doesn't implement - then an exception is thrown.

Like connections, the resultSet objects can carry name-value options. The special options which affect ZOOM-C++'s behaviour are the same as those for ZOOM-C and are described in its documentation (link below). In particular, the preferredRecordSyntax option may be set to a string such as ``USMARC'', ``SUTRS'' etc. to indicate the format in which records should be retrieved; and the elementSetName option indicates whether brief records (``B''), full records (``F'') or some other composition should be used.

The size() method returns the number of records in the result set. Zero is a legitimate value: a search that finds no records is not the same as a search that fails.

Finally, the getRecord method returns the ith record from the result set, where i is zero-based: that is, legitimate values range from zero up to one less than the result-set size. If the method fails, for example because the requested record is out of range, it throws an exception.

4.1. References