Using Variables in Procedures

Working with Procedures, Variables, Sequences, and User Functions 12-19

12.3 Working with Sequences

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

12.3.1 Introduction to Sequences

A Sequence is a variable that increments itself automatically each time it is used. Between two uses, the value can be stored in the repository or managed within an external RDBMS table. Sequences can be strings, lists, tuples or dictionaries. Oracle Data Integrator sequences are intended to map native sequences from RDBMS engines, or to simulate sequences when they do not exist in the RDBMS engine. Non-native sequences’ values can be stored in the Repository or managed within a cell of an external RDBMS table. A sequence can be created as a global sequence or in a project. Global sequences are common to all projects, whereas project sequences are only available in the project where they are defined. Oracle Data Integrator supports three types of sequences: ■ Standard sequences , whose current values ares stored in the Repository. ■ Specific sequences , whose current values are stored in an RDBMS table cell. Oracle Data Integrator reads the value, locks the row for concurrent updates and updates the row after the last increment. ■ Native sequence , that maps a RDBMS-managed sequence. Note the following on standard and specific sequences: ■ Oracle Data Integrator locks the sequence when it is being used for multi-user management, but does not handle the sequence restart points. In other words, the SQL statement ROLLBACK does not return the sequence to its value at the beginning of the transaction. ■ Oracle Data Integrator standard and specific sequences were developed to compensate for their absence on some RDBMS. If native sequences exist, they should be used. This may prove to be faster because it reduces the dialog between the agent and the database. The following sections describe how to create and use sequences.

12.3.2 Creating Sequences

The procedure for creating sequences vary depending on the sequence type. Refer to the corresponding section: ■ Creating Standard Sequences ■ Creating Specific Sequences ■ Creating Native Sequences

12.3.2.1 Creating Standard Sequences

To create a standard sequence:

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

Sequences node in the Others view. 2. Right-click and select New Sequence. The Sequence Editor opens. 12-20 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator

3. Enter the sequence Name, then select Standard Sequence.

4. Enter the Increment.

5. From the File menu, click Save.

The sequence appears in the Projects or Others tree in Designer Navigator.

12.3.2.2 Creating Specific Sequences

Select this option for storing the sequence value in a table in a given data schema. To create a specific sequence:

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

Sequences node in the Others view. 2. Right-click and select New Sequence. The Sequence Editor opens. 3. Enter the sequence Name, then select Specific Sequence. 4. Enter the Increment value. 5. Specify the following sequence parameters:

6. From the File menu, click Save.

The sequence appears in the Projects or Others tree in Designer Navigator.

12.3.2.3 Creating Native Sequences

Select this option if your sequence is implemented in the database engine. Position and increment are fully handled by the database engine. To create a native sequence:

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

Sequences node in the Others view. 2. Right-click and select New Sequence. The Sequence Editor opens. 3. Enter the sequence Name, then select Native Sequence. 4. Select the logical Schema containing your native sequence. Schema Logical schema containing the sequences table Table Table containing the sequence value Column Name of the column containing the sequence value. Filter to retrieve a single row Type in a Filter which will allow Oracle Data Integrator to locate a specific row in the table when the sequence table contains more than one row. This filter picks up the SQL syntax of the data server. For example: CODE_TAB = 3 You can use the Expression Editor to edit the filter. Click Testing query on the DBMS to check the syntax of your expression. Note: When Oracle Data Integrator wants to access the specific sequence value, the query executed on the schema will be SELECT column FROM table WHERE filter.