BUILD a Query Library

BUILD( library );

Form 5 creates an external query library for use in hthor or Roxie, only.

A query library allows a set of related attributes to be packaged as a self contained unit so the code can be shared between different workunits. This reduces the time required to deploy a set of attributes, and also reduces the memory footprint for the set of queries within Roxie that use the library. Also, functionality in the library can be updated without having to re-deploy all the queries that use that functionality.

Query libraries are suitable for packaging together sets of functions that are closely related. They aren't suited for including attributes defined as MACROs--the meaning of a macro isn't known until its parameters are substituted.

The name form of #WORKUNIT names the workunit that BUILD creates as the external library. That name is the external library name used by the LIBRARY function (which provides access to the library from within the query that uses the library). Since the workunit itself is the external query library, BUILD(library) must be the only action in the workunit.


NamesRec := RECORD
  STRING20  FName;
  STRING20  LName;
FilterLibIface1(DATASET(namesRec) ds, STRING search) := INTERFACE
  EXPORT DATASET(namesRec) matches;
  EXPORT DATASET(namesRec) others;

FilterDsLib1(DATASET(namesRec) ds, STRING search) :=
  EXPORT matches := ds(Lname  = search);
  EXPORT others  := ds(Lname != search);