Skip Headers
Oracle® Business Intelligence Enterprise Edition Help
11g Release 1 (11.1.1)
  Go To Table Of Contents
Contents

What Is the Syntax for Referencing Variables?

You can reference variables in analyses, dashboards, KPIs, and agents. How you reference a variable depends on the task that you are performing.

For tasks where you are presented with fields in a dialog, you must specify only the type and name of the variable (not the full syntax), for example, referencing a variable in a filter definition.

For other tasks, such as referencing a variable in a title view, you specify the variable syntax. The syntax you use depends on the type of variable as described in Table 2-1.


Note:

In the syntax, if the "at" sign (@) is not followed by a brace ({), then it is treated as an "at" sign.


Table 2-1 Syntax for Referencing Variables

Type of Variable Syntax Example

Session

@{biServer.variables['NQ_SESSION.variablename']}

where variablename is the name of the session variable, for example DISPLAYNAME.

For a list of system session variables that you can use, see "About System Session Variables" in Metadata Repository Builder's Guide for Oracle Business Intelligence Enterprise Edition.

@{biServer.variables['NQ_SESSION.USER']}

Repository

@{biServer.variables.variablename}

or

@{biServer.variables['variablename']}

where variablename is the name of the repository variable, for example, prime_begin.

@{biServer.variables.prime_begin}

or

@{biServer.variables['prime_begin']}

Presentation or request

@{variables.variablename}[format]{defaultvalue}

or

@{scope.variables['variablename']}

where:

  • variablename is the name of the presentation or request variable, for example, MyFavoriteRegion.

  • (optional) format is a format mask dependent on the data type of the variable, for example #,##0, MM/DD/YY hh:mm:ss. (Note that the format is not applied to the default value.)

  • (optional) defaultvalue is a constant or variable reference indicating a value to be used if the variable referenced by variablename is not populated.

  • scope identifies the qualifiers for the variable. You must specify the scope when a variable is used at multiple levels (analyses, dashboard pages, and dashboards) and you want to access a specific value. (If you do not specify the scope, then the order of precedence is analyses, dashboard pages, and dashboards.)

Note: When using a dashboard prompt with a presentation variable that can have multiple values, the syntax differs depending on the column type. Multiple values are formatted into comma-separated values and therefore, any format clause is applied to each value before being joined by commas.

@{variables.MyFavoriteRegion}{EASTERN REGION}

or

@{MyFavoriteRegion}

or

@{dashboard.variables['MyFavoriteRegion']}

or

(@{myNumVar}[#,##0]{1000})

or

(@{variables.MyOwnTimestamp}[YY-MM-DD hh:mm:ss]{)

or

(@{myTextVar}{A, B, C})

Global

@{global.variables.variablename}

where variablename is the name of the global variable, for example, gv_region. When referencing a global variable, you must use the fully qualified name as indicated in the example.

Note: The naming convention for global variables must conform to EMCA Scripting language specifications for JavaScript. The name must not exceed 200 characters, nor contain embedded spaces, reserved words, and special characters. If you are unfamiliar with JavaScripting language requirements, consult a third party reference.

@{global.variables.gv_date_n_time}


You also can reference variables in expressions. The guidelines for referencing variables in expressions are described in Table 2-2.

Table 2-2 Guidelines for Referencing Variables in Expressions

Type of Variable Guidelines Example

Session

  • Include the session variable as an argument of the VALUEOF function.

  • Enclose the variable name in double quotes.

  • Precede the session variable by NQ_SESSION and a period.

  • Enclose both the NQ_SESSION portion and the session variable name in parentheses.

"Market"."Region"=VALUEOF(NQ_SESSION."SalesRegion")

Repository

  • Include the repository variable as an argument of the VALUEOF function.

  • Enclose the variable name in double quotes.

  • Refer to a static repository variable by name.

  • Refer to a dynamic repository variable by its fully qualified name.

    If you are using a dynamic repository variable, then the names of the initialization block and the repository variable must be enclosed in double quotes ("), separated by a period, and contained within parentheses. For example, to use the value of a dynamic repository variable named REGION contained in a initialization block named Region Security, use this syntax:

    VALUEOF("Region Security"."REGION")

    For more information, see "About Repository Variables" in Metadata Repository Builder's Guide for Oracle Business Intelligence Enterprise Edition.

CASE WHEN "Hour" >= VALUEOF("prime_begin") AND "Hour" < VALUEOF("prime_end") THEN 'Prime Time' WHEN ... ELSE...END

Presentation

  • Use this syntax:

    @{variablename}{defaultvalue}
    

    where variablename is the name of the presentation variable and defaultvalue (optional) is a constant or variable reference indicating a value to be used if the variable referenced by variablename is not populated.

  • To type-cast (that is, convert) the variable to a string, enclose the entire syntax in single quotes, for example:

    '@{user.displayName}'
    

Note: If the @ sign is not followed by a {, then it is treated as an @ sign.

When using a presentation variable that can have multiple values, the syntax differs depending on the column type.

Use the following syntax in SQL for the specified column type in order to generate valid SQL statements:

  • Text — (@{variablename}['@']{'defaultvalue'})

  • Numeric — (@{variablename}{defaultvalue})

  • Date-time — (@{variablename}{timestamp 'defaultvalue'})

  • Date (only the date) — (@{variablename}{date 'defaultvalue'})

  • Time (only the time) — (@{variablename}{time 'defaultvalue'})

"Market"."Region"=@{MyFavoriteRegion}{EASTERN REGION}

or

"Products"."P4 Brand"=(@{myTextVar}['@']{BizTech})

or

"Products"."PO Product Number"=(@{myNumVar}{1000})

or

"Sales Person"."E7 Hire Date"=(@{myDateTimeVar}{timestamp '2013-05-16 00:00:01'})

or

"Time"."Total Fiscal Time"=(@{myDateVar}{date '2013-05-16'})

or

"Time"."Time Right Now"=(@{myTimeVar}{time '00:00:01'})

For multiple values (in specified data types) when using SQL:


If the column type is Text and variablename is passing val1, val2, and val3, the resultant is ('val1', 'val2', 'val3').

or


If the column type is Date and variablename is passing 2013-08-09 and 2013-08-10, the resultant is (date '2013-08-09', date '2013-08-10').

or


If the column type is Date-time and variablename is passing 2013-08-09 00:00:00 and 2013-08-10 00:00:00, the resultant is (timestamp '2013-08-09 00:00:00', timestamp '2013-08-10 00:00:00').

For the specific areas where you can reference variables, see "Where Can I Reference Variables?"