Syntax

Use the following syntax to reference session parameter and parameter values.

Object

Syntax

Example

Session key

$session_key

#$my_account#

Parameter map key

$map{<key>}

#$map_one{'abc'}#

Parameter map entry whose key is defined by a session parameter

$map{$session_key}

#$map_one{$my_account}#

You can add the following elements to further define the macro expression.

Symbol

Purpose

Single quotation marks '

Delineates a literal string that has a single quotation mark as part of the string.

If the single quotation mark displays in a string, such as a query item, the string must be enclosed in a single quotation mark on both sides of the string and the single quotation mark must be doubled. For example, ab'c is written as 'ab''c'

If the single quotation mark displays in a macro, the string must be enclosed in square brackets. For example, ab'c is written as [ab'c]

If the single quotation mark displays in a prompt, there is no need to enclose the string.

To escape a single quotation mark in an expression, use &apos;

Square brackets [ ]

Encloses model objects, such as a namespace or query subject and macro names that contain restricted characters, such as a number sign, hyphen, or space.

Curly brackets, also known as braces { }

Calls a function that is unknown to the parser, such as dateadd in IBM® Db2, and whose first argument is a keyword.

Example:

dateadd
({month},2,<date
expression>)

+ operator

Concatenates two strings, such as 'abc' + 'xyz'

Single quote function (sq)

Surrounds the result of a string expression with single quotation marks. If the single quotation mark displays in a string, such as a query item, the string must be enclosed in a single quotation mark on both sides of the string and the single quotation mark must be doubled. You can use this function to build clauses to test against literal parameter-driven values.

Here is an example:

#sq($my_sp)#

If a session parameter (my_sp) has the value ab'cc, the result is

'ab"cc'

Double quote function (dq)

Surrounds the result of a string expression with double quotation marks. You can use this function to refer to table and column names with non-identifier characters, such as a blank space or a percent sign (%).

Here is an example:

#dq
('Column' + $runLocale)#

If runLocale=en-us, the result is

"Column en-us"

Square bracket function (sb)

Inserts a set of square brackets into the argument to build object references in a model query and model expressions, such as filters and calculations.

Here is an example:

#sb
('my item in ' + $runLocale)#

If runLocale=en-us, the result is

[my item in en-us]