Siebel Analytics Server Administration Guide > Using Variables in a Repository > About Initialization Blocks >

Initializing Session Variables


As with dynamic repository variables, session variables obtain their values from initialization blocks. Unlike dynamic repository variables, however, session variables do not get updated at scheduled time intervals. Instead, the Siebel Analytics Server creates new instances of those variables whenever a user begins a new session. The values remain unchanged for the session's duration.

The Siebel Analytics Server logs all SQL queries issued to retrieve session variable information in the NQQuery.log file when the session's user ID is set to 2 or higher. The default location for the NQQuery.log file is the Log folder in the Siebel Analytics Server software installation folder. For more information about user-level logging, see Administering the Query Log.

Row-Wise Initialization

The Row-Wise Initialization feature allows you to create session variables dynamically and set their values when a session begins. The names and values of the session variables reside in an external database that you access through a connection pool. The variables receive their values from the initialization string that you enter in the Initialization Block dialog box.

Example: Suppose you want to create session variables using values contained in a table named RW_SESSION_VARS. The table contains three columns: USERID, containing values that represent users' unique identifiers; NAME, containing values that represent session variable names; and VALUE, containing values that represent session variable values.

The content of the table is as follows:

USERID
NAME
VALUE
JOHN
LEVEL
4
JOHN
STATUS
FULL-TIME
JANE
LEVEL
8
JANE
STATUS
FULL-TIME
JANE
GRADE
AAA

You create an initialization block and select the Row-Wise Initialization check box (see Creating and Editing Initialization Blocks).

For the initialization string, you enter the following SQL statement:

select NAME, VALUE
from RW_SESSION_VARS
where USERID='VALUEOF(NQ_SESSION.USERID)'

NQ_SESSION.USERID has already been initialized using another initialization block.

The following session variables are created:

Initializing a Variable with a List of Values

You can also use the Row-Wise Initialization feature to initialize a variable with a list of values. You can then use the SQL IN operator to test for values in a specified list.

Example: Using the table values in the previous example, you would enter the following SQL statement for the initialization string:

select `LIST_OF_USERS', USERID
from RW_SESSION_VARS
where NAME='STATUS' and VALUE='FULL-TIME'

This SQL statement populates the variable LIST_OF_USERS with a list, separated by colons, of the values JOHN and JANE; for example, JOHN:JANE. You can then use this variable in a filter, as shown in the following WHERE clause:

where TABLE.USER_NAME = valueof(NQ_SESSION.LIST_OF_USERS)

The variable LIST_OF_USERS contains a list of values, that is, one or more values. This logical WHERE clause expands into a physical IN clause, as shown in the following statement:

where TABLE.USER_NAME in (`JOHN', `JANE')


 Siebel Analytics Server Administration Guide 
 Published: 23 June 2003