How to use Oracle Sequence in Database Adapter

In this post we will see how to use a oracle sequence in database adapter.

In some cases where you want to use the database adapter for inserts data in to a database table , you may want to use native sequencing to populate a primary key for some field.

I have created a below table and sequence in oracle database and i wanted use this table and sequence from SOA using database adapter.

CREATE TABLE TEST_SEQ_TAB (“ID” VARCHAR2(4000 BYTE) NOT NULL ENABLE,
“SOURCE” VARCHAR2(4000 BYTE) NOT NULL ENABLE,
“TARGET” VARCHAR2(4000 BYTE) NOT NULL ENABLE,
“REASON” CLOB,
“CREATE_TIME” TIMESTAMP (6) NOT NULL ENABLE,
“ATTRIBUTE1” VARCHAR2(250 BYTE),
“GUID” VARCHAR2(400 BYTE)
) ;

CREATE SEQUENCE TEST_SEQ INCREMENT BY 1 START WITH 1 NOMAXVALUE MINVALUE 1;

Now i have created a Database adapter to use this sequence.

For using this sequence we have to use “native sequencing” in DB adapter in primary key column.

testseq.JPG

You can see the primary key column in the table is linked with sequence in the mappings file .

seqprimarykey

testseqprimaryid.JPG

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s