Using Variables in Packages

Working with Procedures, Variables, Sequences, and User Functions 12-17 2. Define your ORDERS file datastore in your model and set its resource name to: ORDDWH.FILE_SUFFIX.dat. 3. Use your file datastore normally in your interfaces. 4. Design a package as follows: 1. Drag and drop the FILE_SUFFIX variable to refresh it. 2. Drag and drop all interfaces that use the ORDERS datastore. At runtime, the source file name will be substituted to the appropriate value.

12.2.3.7 Using Variables in a Server URL

There are some cases where using contexts for different locations is less appropriate than using variables in the URL definition of your data servers. For example, when the number of sources is high 100, or when the topology is defined externally in a separate table. In these cases, you can refer to a variable in the URL of a server’s definition. Suppose you want to load your warehouse from 250 source applications - hosted in Oracle databases - used within your stores. Of course, one way to do it would be to define one context for every store. However, doing so would lead to a complex topology that would be difficult to maintain. Alternatively, you could define a table that references all the physical information to connect to your stores and use a variable in the URL of your data server’s definition. Example 12–3 illustrates how you would implement this in Oracle Data Integrator: Example 12–3 Referring to a Variable in the URL of a Server’s Definition

1. Create a StoresLocation table as follows:

2. Create three variables in your EDW project:

■ STORE_ID: takes the current store ID as an input parameter ■ STORE_URL: refreshes the current URL for the current store ID with SELECT statement: select StoreUrl from StoresLocation where StoreId = EDW.STORE_ID ■ STORE_ACTIVE: refreshes the current activity indicator for the current store ID with SELECT statement: select IsActive from StoresLocation where StoreId = EDW.STORE_ID Note: The variable in the datastore resource name must be fully qualified with its project code. When using this mechanism, it is not possible to view the data of your datastore from within Designer. Table 12–6 Stores Location table StoreID Store Name Store URL IsActive 1 Denver 10.21.32.198:1521:ORA1 YES 2 San Francisco 10.21.34.119:1525:SANF NO 3 New York 10.21.34.11:1521:NY YES ... ... ... ... 12-18 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator 3. Define one physical data server for all your stores and set its JDBC URL to: jdbc:oracle:thin:EDW.STORE_URL 4. Define your package for loading data from your store. The input variable STORE_ID will be used to refresh the values for STORE_URL and STORE_ACTIVE variables from the StoresLocation table. If STORE_ACTIVE is set to “YES”, then the next 3 steps will be triggered. The interfaces refer to source datastores that the agent will locate according to the value of the STORE_ URL variable. To start such a scenario on Unix for the New York store, you would issue the following operating system command: startscen.sh LOAD_STORE 1 PRODUCTION “EDW.STORE_ID=3” If you want to trigger your LOAD_STORE scenario for all your stores in parallel, you would simply need to create a procedure with a single SELECTaction command as follows: The LOAD_STORE scenario will then be executed for every store with the appropriate STORE_ID value. The corresponding URL will be set accordingly. Refer to Binding Source and Target Data and Section 4.3, Managing Agents for further details.

12.2.3.8 Using Variables in On ConnectDisconnect Commands

Variables can be used in the On connectDisconnect SQL commands. See Section 4.2.2.3, Creating a Data Server Advanced Settings for more information.

12.2.3.9 Passing a Variable to a Scenario

It is also possible to pass a variable to a scenario in order to customize its behavior. To do this, pass the name of the variable and its value on the OS command line which executes the scenario. For more information, see Section 20.3.2, Executing a Scenario from a Command Line .

12.2.3.10 Generating a Scenario for a Variable

It is possible to generate a single step scenario for running a variable. How to generate a scenario for a variable is covered in Section 13.2, Generating a Scenario . Table 12–7 SELECTaction command Source Technology Oracle technology of the data server containing the StoresLocation table. Source Logical Schema Logical schema containing the StoresLocation table. Source Command Select StoreId From StoresLocation Target Technology ODITools Target Logical Schema None Target Command SnpsStartScen “-SCEN_NAME=LOAD_STORE” “-SCEN_VERSION=1” “-SYNC_MODE=2” “-EDW.STORE_ID=StoreId”