Select the Target Technology and if the Multi-Connections box is checked also

12-6 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator – A valid RDBMS technology that supports your SQL statement, such as Teradata or Oracle etc. – A logical schema that indicates where it should be executed. At runtime, this logical schema will be converted to the physical data server location selected to execute this statement. – Additional information for transaction handling as described further in section Handling RDBMS Transactions. ■ Operating System Commands : Useful when you want to run an external program. In this case, your command should be the same as if you wanted to execute it from the command interpreter of the operating system of the Agent in charge of the execution. When doing so, your objects become dependent on the platform on which the agent is running. To write an operating system command, select “Operating System” from the list of technologies of you current step. It is recommended to use for these kind of operations the OdiOSCommand tool as this tool prevents you from calling and setting the OS command interpreter. ■ ODI Tools : ODI offers a broad range of built-in tools that you can use in procedures to perform some specific tasks. These tools include functions for file manipulation, email alerts, event handling, etc. They are described in detail in the online documentation. To use an ODI Tool, select ODITools from the list of technologies of your current step. ■ Scripting Language : You can write a command in any scripting language supported by Oracle Data Integrator. By default, ODI includes support for the following scripting languages that you can access from the technology list box of the current step: Jython, Groovy, NetRexx, and Java BeanShell. Using the Substitution API It is recommended that you use the ODI substitution API when writing commands in a procedure to keep it independent of the context of execution. You can refer to the online documentation for information about this API. Common uses of the substitution API are given below: ■ Use getObjectNameto obtain the qualified name of an object in the current logical schema regardless of the execution context, rather than hard coding it. ■ Use getInfo to obtain general information such as driver, URL, user etc. about the current step ■ Use getSession to obtain information about the current session ■ Use getOption to retrieve the value of a particular option of your procedure ■ Use getUser to obtain information about the ODI user executing your procedure. Handling RDBMS Transactions Oracle Data Integrator procedures include an advanced mechanism for transaction handling across multiple steps or even multiple procedures. Transaction handling applies only for RDBMS steps and often depends on the transaction capabilities of the underlying database. Within procedures, you can define for example a set of steps that would be committed or rolled back in case of an error. You can also define up to 10 from 0 to 9 independent sets of transactions for your steps on the same server. Using transaction handling is of course recommended when your underlying database supports transactions. Note that each transaction opens a connection to the database. Working with Procedures, Variables, Sequences, and User Functions 12-7 However, use caution when using this mechanism as it can lead to deadlocks across sessions in a parallel environment. Binding Source and Target Data Data binding in Oracle Data Integrator is a mechanism in procedures that allows performing an action for every row returned by a SQL SELECT statement. To bind source and target data: 1. Open the Command Line Editor.

2. In the Command on Source tab, specify the SELECT statement.

3. In the Command on Target tab, specify the action code. The action code can itself

be an INSERT, UPDATE or DELETE SQL statement or any other code such as an ODI Tool call, Jython or Groovy. Refer to Appendix A, Oracle Data Integrator Tools Reference for details about the ODI Tools syntax. The values returned by the source result set can be referred to in the action code using the column names returned by the SELECT statement. They should be prefixed by colons “:” whenever used in a target INSERT, UPDATE or DELETE SQL statement and will act as “bind variables”. If the target statement is not a DML statement, then they should be prefixed by a hash “” sign and will act as substituted variables. Note also that if the resultset of the Source tab is passed to the Target tab using a hash sign, the target command is executed as many times as there are values returned from the Source tab command. The following examples give you common uses for this mechanism. There are, of course, many other applications for this powerful mechanism. Example 12–1 Loading Data from a Remote SQL Database Suppose you want to insert data into the Teradata PARTS table from an Oracle PRODUCT table. Table 12–1 gives details on how to implement this in a procedure step. ODI will implicitly loop over every record returned by the SELECT statement and bind its values to “:MY_PRODUCT_ID” and “:PRODUCT_NAME” bind variables. It then triggers the INSERT statement with these values after performing the appropriate data type translations. Table 12–1 Procedure Details for Loading Data from a Remote SQL Database Source Technology Oracle Source Logical Schema ORACLE_INVENTORY Source Command select PRD_ID MY_PRODUCT_ID, PRD_NAME PRODUCT_NAME, from =odiRef.getObjectNameL,PRODUCT,D Target Technology Teradata Target Logical Schema TERADATA_DWH Target Command insert into PARTS PART_ID, PART_ORIGIN, PART_NAME values :MY_PRODUCT_ID, ’Oracle Inventory’, :PRODUCT_NAME