Click or drag to resize
SQL_Where

[This is preliminary documentation and is subject to change.]

The TOPICA Basic function SQL_Where is used to build an SQL WHERE-clause from a logical expression.

If the input parameter (the logical expression) is the empty string, the result is empty.

Use this function to construct SQL queries (for use in reports etc.), that may or may not have WHERE-clauses, depending on the context. A very relevant example is the situation where reports may be started WITH an organizational unit in context as well as WITHTOUT an organizational unit in context.

Syntax
SQL_Where(SQLExpression)
Parameters

Name

Type

Description

SQLExpression

String

String containing a logical SQL expression, e.g. "SomeField=2".

Returns

SQL WHERE-clause

Type: String.

Examples
SQL_Where(SQL_And("FieldX=2", "FieldY='yyy'"))

Result: "WHERE (FieldX=2) AND (FieldY='yyy')".

SQL_Where("FieldX=2")

Result: "WHERE FieldX=2".

SQL_Where("")

Result: "".

See also TOPICA Report Format for a real-world example showing how to deal with the situation where a report may be started WITH an organizational unit in context as well as WITHTOUT an organizational unit in context.