Introduction to Procedures Working with Procedures

Working with Procedures, Variables, Sequences, and User Functions 12-5 Most of the procedures use only commands on the target. In some cases, it is required to read data and perform actions using this data. For these use case, you specify the command to read the data in the Command on Source tab and the actions performed with this data in the Command on Target tab. Refer to Binding Source and Target Data for more information. Skip step 6 if you are not in this use case.

6. For Multi-Connections Procedures, repeat step 5 for the Command on Source tab.

7. In the Options section, check the Always Execute box if you want this command

to be executed all the time regardless of the option values. Otherwise, check the options of type boolean that control the command execution. At run-time, if any of the selected options is set to Yes, the command is executed.

8. From the File menu, click Save.

To duplicate a command:

1. Go to the Details tab of the Procedure.

2. Select the command to duplicate.

3. Right-click then select Duplicate. The Command Line Editor opens. It is a copy of

the selected command.

4. Make the necessary modifications and from the File menu, click Save.

The new command is listed on the Details tab. To delete a command line:

1. Go to the Details tab of the Procedure.

2. Select the command line to delete.

3. From the Editor toolbar, click Delete.

The command line will disappear from the list. To order the command lines: The command lines are executed in the order displayed in the Details tab of the Procedure Editor. It may be necessary to reorder them.

1. Go to the Details tab of the Procedure.

2. Click on the command line you wish to move. 3. From the Editor toolbar, click the arrows to move the command line to the appropriate position. Writing Code in Procedures Commands within a procedure can be written in several languages. These include: ■ SQL : or any language supported by the targeted RDBMS such as PLSQL, Transact SQL etc. Usually these commands can contain Data Manipulation Language DML or Data Description Language DDL statements. Using SELECT statements or stored procedures that return a result set is subject to some restrictions. To write a SQL command, you need to select: Note: The transaction, commit and transaction isolation options work only for technologies supporting transactions. 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.