Thursday, November 18, 2010

Repository Variables in OBIEE

A repository Variable has a single value at any point of time. There are two types of Repository variables. Static and Dynamic.

          Repository variables can be used instead of literals or constants in expression builders in the Administration Tool. The Oracle BI Server will substitute the value of the repository variable for the variable itself in the metadata.
Static Repository Variables:
The value of a static repository value is initialized in the Variable dialog box. This value persists, and does not change until an Oracle BI Administrator decides to change it.
Example
Suppose you want to create an expression to group times of day into different day segments. If Prime Time were one of those segments and corresponded to the hours between 5:00 PM and 10:00 PM, you could create a CASE statement like the following:
CASE WHEN "Hour" >= 17 AND "Hour" < 23 THEN 'Prime Time' WHEN... ELSE...END
where Hour is a logical column, perhaps mapped to a timestamp physical column using the date-and-time Hour(<<timeExpr>>) function.
Rather than entering the numbers 17 and 23 into this expression as constants, you could use the Variable tab of the Variable dialog box to set up a static repository variable named prime_begin and initialize it to a value of 17, and create another variable named prime_end and initialize it to a value of 23.
After created, variables are available for use in expression builders. In an expression builder, click on the Repository Variables folder in the left pane to display all repository variables (both static and dynamic) in the middle pane by name.
Variables should be used as arguments of the function VALUEOF( ).
For example, the following CASE statement is identical to the one explained in the preceding example except that variables have been substituted for the constants.
CASE WHEN "Hour" >= VALUEOF("prime_begin")AND "Hour" < ALUEOF("prime_end") THEN 'Prime Time' WHEN ... ELSE...END.

Dynamic Repository Variables

You initialize dynamic repository variables in the same way as static variables, but the values are refreshed by data returned from queries. When defining a dynamic repository variable, you will create an initialization block or use a pre-existing one that contains a SQL query. You will also set up a schedule that the Oracle BI Server will follow to execute the query and periodically refresh the value of the variable.


Example


Dynamic repository variables are very useful for defining the content of logical table sources. For example, suppose you have two sources for information about orders. One source contains recent orders and the other source contains historical data.

You need to describe the content of these sources on the Content tab of the Logical Table Source dialog box. Without using dynamic repository variables, you would describe the content of the source containing recent data with an expression such as:
Orders.OrderDates."Order Date" >= TIMESTAMP '2001-06-02 00:00:00'

This content statement will become invalid as new data is added to the recent source and older data is moved to the historical source. To accurately reflect the new content of the recent source, you would have to modify the fragmentation content description manually. Dynamic repository values can be set up to do it automatically.

Another suggested use for dynamic repository values is in WHERE clause filters of logical table sources, that are defined on the Content tab of the Logical Table Source dialog box.
The values of dynamic repository variables are set by queries defined in Variable Initialization blocks.

A common use of these variables is to set filters for use in Oracle BI Presentation Services. For example, to filter a column on the value of the dynamic repository variable CurrentMonth, set the filter to the Variable CurrentMonth.

Step by step process of creating repository variable
   1.  From the Administration Tool menu bar, choose Manage > Variables.

Now the variable manager dialogue box appers...
  1. In the Variable Manager dialog box, from the menu bar, choose Action>New>Repository>Variable.

Repository variable dialogue box is as follows...
  1. In the Variable dialog box, type a Variable name.
    Names for all variables should be unique. The names of system session variables are reserved and cannot be used for other types of variables.

In the Variables dialog box, select the type of variable: Static or Dynamic.
  1. The name of the dialog box changes to reflect the type of variable that you select.
  2. (Dynamic repository variables) Use the Initialization Block drop-down list to select an existing initialization block that will be used to refresh the value on a continuing basis.
    To create a new initialization block, click New.

    6.   (Dynamic or static variables) To add a Default initializer value, perform one of the following steps:
  •  To use the Expression Builder, click the ellipsis button to the right of the Default initializer work space.
  • Type the value into the Default initializer text box.For static repository variables, the value you specify in the Default initializer window persists. It will not change unless you change it. If you initialize a variable using a character string, enclose the string in single quotes ( ' ).

  1. Click OK.

1 comment:

  1. It helped me to understand the variables concept.. Thanks!!

    ReplyDelete