@DB2Schema (Formula Language)

Given the name of a database as a text string, returns a text string containing the DB2® schema of that database if it is a db2nsf database or the empty string if it is not a db2nsf database.

Note: This @function is new with Release 7.

Syntax

@DB2Schema( server : file )

@DB2Schema( server ; replicaID )

Parameters

server

Text. The name of the server.

file

Text. The path and file name of the database. Specify the database path and file name using the appropriate format for the operating system.

replicaID

Text. The replica ID of the database.

Return value

schema

Text. The DB2® schema of the nsf database indicated by server : file or server ; replicaID. The empty string ("") is returned if the database is a non-DB2 database. Returns an error via @Error if:

  • The server cannot be reached
  • The database specified in file or replicaID cannot be found

Usage

@DB2Schema is intended to be used with Query Views, where a DB2® SQL query returns a result set for display. This SQL query is an evaluated formula, and may incorporate @functions in the query formula, the evaluation of which results in the text string of the SQL executed in DB2®. To SELECT from a Domino® Access View (DAV) within the current db2nsf's schema, the DAV table must be qualified by the schema name. Otherwise, DB2® uses the accessing user's name as the schema name. @DB2Schema allows the schema name to be dynamically specified within a query formula.

This function also works in all contexts where @function use is supported, including view selection formulas, and column formulas.

Examples

  1. This formula returns the schema name FRITES if a database exists and is DB2® backed or "" if it is not DB2® backed.
    @DB2Schema( "Belgium" : "mail\\frites.nsf" )
  2. This formula returns DB2® information about a database using its replica ID instead of its file name:
    @DB2Schema("Cheshire";"852556DO:00576146")
  3. These formulas both return DB2® information about the current database:
    @DB2Schema(@DbName)

  4. This example uses @DB2Schema in a query to pull firstname and lastname information from the dav1 table in the same schema as the current database:
    "SELECT firstname, lastname FROM " + @DB2Schema( @DbName ) + ".dav1"
  5. This example uses @DB2Schema with error handling in a column formula to return the schema of the local db2nsf database referenced in the dbname field of the document:
    @If(@IsError(@DB2Schema(@DBName));"Error")

  6. This example first uses @IsDB2 to find out if a connection to DB2® is available, and if the local database referenced in the dbname field of the document is a DB2® database, so that a more meaningful error message may be displayed from @DB2Schema:
    result1 := @IsDB2("":dbname);
    result2 := @DB2Schema(@DBName)
    @If(@IsError(result1);"Unable to find database or lost server connection";
    result1;@If(@IsError(result2);
    "Unable to find database or lost server connection";result2);
    "Not a DB2 database");