If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Federation Server to Oracle 10g - Sequences

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-09, 15:42
rbrewer rbrewer is offline
Registered User
 
Join Date: Feb 2009
Posts: 3
Federation Server to Oracle 10g - Sequences

We've been using DB2 as a relational repository for data that is shared by our Mainframe applications (Cobol, DL-1, z/VSE) and our distributed applications (Java, Oracle 10g, Linux).

We are currently evaluating Federation Server to access Oracle directly from the Mainframe. There is no z/VSE Oracle client.

I have Federation Server running on SuSe Linux and I'm pointing to an Oracle 10g database on another Linux server that contains a duplicate of part of my DB2 production database (Tables, Views, etc.).

In DB2, we used Identity columns but this doesn't exist in Oracle so I'm using a Sequence with an ON INSERT trigger to duplicate the process.

In DB2, right after the insert, I can say,
SELECT IDENTITY_VAL_LOCAL()
INTO :ACCT-ACCOUNT-ID
FROM SYSIBM.SYSDUMMY1
to get the value of the identity column for use as a key when inserting child rows.

This doesn't exist in Oracle (that I know of).

From the DB2 side, how can I get the last value of the sequence?

SELECT sequence_name.CURRVAL from DUAL; fails because DUAL doesn't exist and the sequence name is not defined.

Is it possible to define a Nickname for an Oracle Sequence?

Ideas?
Reply With Quote
  #2 (permalink)  
Old 02-04-09, 16:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You could create a UDF on the Oracle side and a function mapping on the DB2 side.
Reply With Quote
  #3 (permalink)  
Old 02-05-09, 10:40
rbrewer rbrewer is offline
Registered User
 
Join Date: Feb 2009
Posts: 3
Solution

That's what I did. Since there are several primary key columns that were identity columns in DB2 and are not being loaded by sequences in Oracle, I created a stored procedure and defined it to DB2. An insert to the table executes the ON INSERT trigger that populates the column from the sequence. The program calls the stored procedure and passes the column name, the stored procedure branches to the correct "SELECT sequenceName.CURRVAL from DUAL" statement and returns the value.

We did find that with DB2 VM/VSE there is a limit of 18 characters for a stored procedure name (including the schema qualifier) so had to change the nickname to abreviate the name.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On