@Functions for query views

@DB2Schema

When a Notes® database is stored in DB2®, the information contained in that database is contained in tables that reside in a single DB2® grouping construct known as a schema. All references to those tables use the table name preceded by the schema name, separated by a period (for example, "schema.table").

When an application developer wishes to use a SELECT statement in a query view, the name of the DB2® Access view (DAV) against which the query is being run must prefix the name of the DAV with the schema name. Otherwise DB2® uses the Domino® server's DB2® user name as the schema in which to look for the table. For example, if you run a query view with a SELECT statement against a table called dav1 and the designer has not used the schema name, DB2® will interpret the location of that table as residing in <db2user>.dav1.

To avoid this, the application developer can look up the schema name from the catalog table using the query:

SELECT SCHEMA FROM DOMINO.SCHEMAS WHERE filepath = '<path to db2nsf>

However, having to do this each time a schema name is needed can be inconvenient.

Moreover, if the DB2® enabled Notes® database is copied using File - Database - Copy, the new copy still refers to the original database's Domino® tables. So any query views executed against these DB2® enabled Notes® databases would refer to the original table source.

A quicker and easier way to determine the schema name of a DB2® enabled Notes® database is to use the @ function @DB2Schema, which, when used in a query formula, returns the name of the DB2® schema for a specified DB2® enabled Notes® database. In query views, @functions may be incorporated in the construction of the query formula, the evaluation of which results in a text string. All contexts in which an @function may be used are supported. This includes view selection formulas and column formulas.

A sample query formula using @DB2Schema:

SELECT firstname, lastname FROM " + @DB2Schema( @DbName ) + ".dav1
Note: Use of @DB2Schema in, for example, column names causes @ERRORs if the user has replicated to a native Notes® database. Proper handling of errors via @IF, or other means, is recommended.

@IsDB2

The @IsDB2 function accepts a text argument representing the path, with the same rules that govern the use of @DB2Schema. It returns either TRUE, meaning the DB2® enabled Notes® database is stored in DB2®, or FALSE, meaning it is stored in native NSF format (or that the nature of source database cannot be determined).