Using Variables in ODI - The Timestamp Example
Using Variables in ODI - The Timestamp Example
Detailed instructions will be provided throughout this post to describe how to reproduce this
case. We will create 2 variables in ODI for this example. Then we will implement the following
logic:
- Store current date and time in variable1 as we start our process
- Filter out the data from the table on using variable2 that contains the data and time of the last
operation
- Update variable2 with the value of variable1
- Run again!
The examples given below assume that we are using an Oracle database, but can easily be
adapted to work on any other database.
1. VARIABLES SETUP IN ODI
1.1 Variables Definition
1.1.1 General Information
The first step is to create two variables in ODI. The first variable will be used to store the date
and time at which we started the process only for the duration of the process. The second
variable will be used to save that date for the next iteration of the package.
To create a variable in ODI, expand your project and right-click on the Variables folder. Then
select Insert Variable
Select any logical schema on Oracle and type the following SQL query:
Select SYSDATE from DUAL
Note:: You can run the query to make sure it is valid. Click the refresh button in the above
window. Then close the variable definition window, and check in the ODI Logs that the query
runs successfully. You can then re-open the variable definition window, and check the resulting
value in the History tab of the variable.
Click Ok to save your first variable.
1.1.3 Second Variable: LastUpdate
We will name our second variable LastUpdate.
Set the data type to Alphanumeric. The default value will be the original start date (basically
the date for the oldest recors in our source file. (be careful here with the date format).
01-JAN-1997 00:00:01
No need to put a refresh value here. (Though an alternative may have been to put here a query to
retrieve the oldest date in the source system!)
Click Ok to save your second variable
Both variables can be seen in the Project Tree if you expand the Variables entry.
Operator as
Select () from () where HIRE_DATE>=#SALES.LastUpdate
Even though the variable value is not visible here, we know that ODI has recognized the variable
as it has inserted the project code. This is good news and guaranties that the value will properly
be substituted at runtime.
If you want to see the value taken by the variable at runtime, look at the History tab in the
variable definition, or look at the Variables folder in the operator (under the session ID) and
then check out the history tab of all variables used in this execution.