Creating Variables Working with Variables

Working with Procedures, Variables, Sequences, and User Functions 12-15 precede the variable by the : character, and make sure that the datatype being searched is compatible with that of the variable. For example: update CLIENT set LASTDATE = sysdate where DATE_YEAR =:GLOBAL.YEAR You can drag-and-drop a variable into most expressions with the Expression Editor.

12.2.3.3 Using Variables in Object Properties

It is also possible to use variables as substitution variables in graphical module fields such as resource names or schema names in the topology. You must use the fully qualified name of the variable Example: GLOBAL.MYTABLENAME directly in the Oracle Data Integrator graphical modules field. Using this method, you can parameterize elements for execution, such as: ■ The physical names of files and tables Resource field in the datastore or their location Physical schemas schema data in the topology ■ Physical Schema ■ Data Server URL

12.2.3.4 Using Variables in Procedures

You can use variables anywhere within your procedures’ code as illustrated in the Table 12–4 . Table 12–3 Examples of how to use Variables in Interfaces Type Expression Mapping ‘PRODUCT_PREFIX’ || PR.PRODUCT_ CODE Concatenates the current project’s product prefix variable with the product code. As the value of the variable is substituted, you need to enclose the variable with single quotes because it returns a string. Join CUS.CUST_ID = DEMO.UID 1000000 + FF.CUST_NO Multiply the value of the UID variable of the DEMO project by 1000000 and add the CUST_NO column before joining it with the CUST_ID column. Filter ORDERS.QTY between MIN_QTY and MAX_QTY Filter orders according to the MIN_QTY and MAX_ QTY thresholds. Option Value TEMP_FILE_NAME: DEMO.FILE_NAME Use the FILE_NAME variable as the value for the TEMP_FILE_NAME option. Table 12–4 Example of how to use Variables in a Procedure Step ID: Step Type Step Code Description 1 SQL Insert into DWH.LOG_TABLE_ NAME Values 1, ‘Loading Step Started’, current_date Add a row to a log table that has a name only known at runtime 2 Jython f = open‘DWH.LOG_FILE_ NAME’, ‘w’ f.write‘Inserted a row in table s’ ‘DWH.LOG_ TABLE_NAME’ f.close Open file defined by LOG_ FILE_NAME variable and write the name of the log table into which we have inserted a row. 12-16 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator You should consider using options rather than variables whenever possible in procedures. Options act like input parameters. Therefore, when executing your procedure in a package you would set your option values to the appropriate values. In the example of Table 12–4 , you would write Step 1’s code as follows: Insert into =snpRef.getOption“LogTableName” Values 1, ‘Loading Step Started’, current_date Then, when using your procedure as a package step, you would set the value of option LogTableName to DWH.LOG_TABLE_NAME.

12.2.3.5 Using Variables within Variables