Repeat these operations for each option that is required for the procedure.

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 12-8 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator When batch update and array fetch are supported by the target and source technologies respectively, ODI prepares arrays in memory for every batch, making the overall transaction more efficient. Example 12–2 Sending Multiple Emails Suppose you have a table that contains information about all the people that need to be warned by email in case of a problem during the loading of your Data Warehouse. You can do it using a single procedure step as described in Table 12–2 . The “–TO” parameter will be substituted by the value coming from the “Email” column of your source SELECT statement. The “OdiSendMail” command will therefore be triggered for every operator registered in the “Operators” table.

12.1.3 Using Procedures

A procedure can be used in the following ways: ■ Executing the Procedure directly in Designer Navigator for testing its execution. ■ Using a Procedure in a Package along with interfaces and other development artifacts for building a data integration workflow. ■ Generating a Scenario for a Procedure for launching only this procedure in a run-time environment.

12.1.3.1 Executing the Procedure

To run a procedure:

1. In the Project view of the Designer Navigator, select the procedure you want to

execute. Note: This mechanism is known to be far less efficient than a fast or multi load in the target table. You should only consider it for very small volumes of data. The section Using the Agent in the Loading Strategies further discusses this mechanism. Table 12–2 Procedure Details for Sending Multiple Emails Source Technology Oracle Source Logical Schema ORACLE_DWH_ADMIN Source Command Select FirstName FNAME, EMailaddress EMAIL From =odiRef.getObjectNameL,Operators,D Where RequireWarning = ’Yes’ Target Technology ODITools Target Logical Schema None Target Command OdiSendMail -MAILHOST=my.smtp.com -FROM=adminmycompany.com “-TO=EMAIL” “-SUBJECT=Job Failure” Dear FNAME, I’m afraid you’ll have to take a look at ODI Operator, because session =snpRef.getSession“SESS_NO” has just failed -Admin