Generating a Scenario for a Variable

12-22 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator ■ In the SQL statement insert into fac select :NO_FAC_NEXTVAL, date_ fac, mnt_fac the value of a standard or specific sequence will be incremented only once, even if the SQL statement processes 10,000 rows, because the agent does not process each record, but just sends the command to the database engine. A native sequence will be incremented for each row. ■ To increment the value of a standard or specific sequence for each row, the data must pass through the agent. To do this, use a KM or procedure that performs a SELECT on the source command and an INSERT on the target command: SELECT date_fac, mnt_fac on the source connection INSERT into FAC ORDER_NO, ORDER_DAT, ORDER_AMNT values :NO_FAC_NEXTVAL, :date_fac, :mnt_fac on the target connection Sequence Scope Unlike for variables, you do not need to state the scope of sequences explicitly in code.

12.3.3.1 Tips for Using Standard and Specific Sequences

To make sure that a sequence is updated for each row inserted into a table, each row must be processed by the Agent. To make this happen, follow the steps below:

1. Make the mapping containing the sequence be executed on the target.

2. Set the mapping to be active for inserts only. Updates are not supported for

sequences.

3. If you are using an incremental update IKM, you should make sure that the

update key in use does not contain a column populated with the sequence. For example, if the sequence is used to load the primary key for a datastore, you should use an alternate key as the update key for the interface.

4. If using Oracle Data Integrator sequences with bind syntax :SEQUENCE_

NAME_NEXTVAL, you must configure the data flow such that the IKM transfers all the data through the agent. You can verify this by checking the generated integration step in Operator. It should have separate INSERT and SELECT commands executed on different connections, rather than a single SELECT...INSERT statement. Limitations of Sequences Sequences have the following limitations: ■ A column mapped with a sequence should not be checked for not null. ■ Similarly, static control and flow control cannot be performed on a primary or alternate key that references the sequence.

12.3.3.2 Identity Columns

Certain databases also natively provide identity columns, which are automatically populated with unique, self-incrementing values. When populating an identity column, you should follow these steps: 1. The mapping loading the identity column should be blank and inactive. It should not be activated for inserts or updates. Working with Procedures, Variables, Sequences, and User Functions 12-23 2. If you are using incremental update IKMs, make sure that the update key in use does not contain the identity column. If the identity column is part of the primary key, you should define an alternate key as the update key for the interface. Limitations of Identity Columns Identity columns have the following limitations: ■ Not null cannot be checked for an identity column. ■ Static and flow control cannot be performed on a primary or alternate key containing the identity column.

12.4 Working with User Functions

This section provides an introduction to user functions and describes how to create and use user functions in Oracle Data Integrator.

12.4.1 Introduction User Functions

User functions are used for defining customized functions that can be used in interfaces or procedures. It is recommended to use them in your projects when the same complex transformation pattern needs to be assigned to different datastores within different interfaces. User functions improve code sharing and reusability and facilitate the maintenance and the portability of your developments across different target platforms. User functions are implemented in one or more technologies and can be used anywhere in mappings, joins, filters and conditions. Refer to Section 12.4.3, Using User Functions . A function can be created as a global function or in a project. In the first case, it is common to all projects, and in the second, it is attached to the project in which it is defined. User functions can call other user functions. A user function cannot call itself recursively. The following sections describe how to create and use user functions.

12.4.2 Creating User Functions

To create a user function:

1. In Designer Navigator select the User Functions node in a project or the Global

User Functions node in the Others view. 2. Right-click and select New User Function. The User Function Editor opens. 3. Fill in the following fields: ■ Name : Name of the user function, for example NullValue Note: Aggregate functions are not supported User Functions. The aggregate function code will be created, but the GROUP BY expression will not be generated.