Siebel Business Analytics Server Administration Guide > SQL Reference > SQL Reference >

Conversion Functions


The conversion functions convert a value from one form to another.

Cast

Changes the data type of an expression or a null literal to another data type. For example, you can cast a customer_name (a data type of Char or Varchar) or birthdate (a datetime literal). The following are the supported data types to which the value can be changed:

CHARACTER, VARCHAR, INTEGER, FLOAT, SMALLINT, DOUBLE PRECISION, DATE, TIME, TIMESTAMP, BIT, BIT VARYING

NOTE:  Depending on the source data type, some destination types are not supported. For example, if the source data type is a BIT string, the destination data type has to be a character string or another BIT string.

The following describes unique characteristics of the CHAR and VARCHAR data types:

  • Casting to a CHAR data type. You must use a size parameter. If you do not add a size parameter, a default of 30 will be added. Syntax options appear in the following list:
    • It is recommended that you use the following syntax:

    CAST (expression|NULL AS CHAR(n) )

    For example, CAST (companyname AS CHAR(35) )

    • You can use the following syntax:

    CAST (expression|NULL AS datatype )

    For example, CAST (companyname AS CHAR )

    NOTE:  If you use this syntax, Siebel Business Analytics will explicitly convert and store as CAST (expression|NULL AS CHAR(30) )

  • Casting to a VARCHAR data type. The Administration Tool requires that you use a size parameter. If you omit the size parameter, you cannot can save the change.

Choose

Takes an arbitrary number of parameters and returns the first item in the list that the user has permission to see.

Syntax:

CHOOSE (expression1, expression2, ..., expressionN)

For example, a single query can be written to return security-based revenue numbers for the entire organization. The function could look like the following:

choose(L1-Revenue, L2-Revenue, L3-Revenue, L4-Revenue)

If the user issuing this function has access to the column L1-Revenue, then that column value would be returned. If the user does not have visibility to the column L1-Revenue but does have visibility to L2-Revenue, then L2-Revenue is returned.

IfNull

Tests if an expression evaluates to a null value, and if it does, assigns the specified value to the expression.

Syntax:

IFNULL (expression, value)

VALUEOF( )

Use the VALUEOF function in an expression builder or filter to reference the value of a repository variable defined in Oracle's Siebel Analytics Administration Tool. You can also use the VALUEOF function when you edit the SQL for a request from the Advanced tab in Oracles Siebel Business Analytics Answers.

Variables should be used as arguments of the VALUEOF function. Refer to static repository variables by name. For example, to use the value of a static repository variables named prime_begin and prime_end:

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

You need to refer to a dynamic repository variable by its fully qualified name. If you are using a dynamic repository variable, the names of the initialization block and the repository variable need to 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 an initialization block named Region Security, this is an example of the proper syntax to use:

SalesSubjectArea.Customer.Region =

VALUEOF("Region Security"."REGION")

The names of session variables need to be preceded by NQ_SESSION, separated by a period, and contained within parentheses. If the variable name contains a space, enclose the name in double quotes ( " ). For example, to use the value of a session variable named REGION, this is an example of the proper syntax to use in an expression builder (filter):

"SalesSubjectArea"."Customer"."Region" = VALUEOF(NQ_SESSION.REGION)

NOTE:  Although using initialization block names with session variables (just as with other repository variables) may work, you should use NQ_SESSION. NQ_SESSION acts like a wild card that matches all initialization block names. This allows the administrator to change the structure of the initialization blocks in a localized manner without impacting reports.

Siebel Business Analytics Server Administration Guide