Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 replication problem v8

Status
Not open for further replies.

vanwilder

Vendor
Mar 15, 2005
2
0
0
ZA
Hi guys

I have a tricky scenario which I need some expert advice on. I'm going try and keep this as simple as possible.

I have a database table which we'll call TABLE1. Inside TABLE1 there are a number of columns of which the first column is ID. ID is an auto-generate column which starts with 1 and increments by +1 for every insert made into the table by the application.

I'm busy setting up replication to a DR database which will basically be a replica of the production database. Problem is that with replication because of the ID column being an auto-generate, the apply program is unable to copy changes across to the DR database and insert the values into TABLE1 as the ID column is an auto-generate field.

I've looked at setting up other replication scenarios like update anywhere etc. but so far what I have tried has failed with the exact same error on the ID column(darn auto-generate!).

Changing the application to insert a record ID into the ID column is not an option I've been told. So, I need to know if I can somehow use a formula or the default column value option or some kind of function to do the following:

When a record is copied across via replication from the production database, the ID field must be able to be inserted into the ID field of the DR database. However, if a record is inserted into the DR database from let’s say the command line or the application and no ID is supplied with the insert statement for the ID column, a check must be done to see what the last (max) ID was in the ID column, increment that ID by +1 and insert the remaining data plus the incremented ID value.

Example:
The replication program inserts an ID of 28889. The local application of the DR machine inserts data for all columns except ID. The ID column must then be automatically generated as 28890.

So it’s basically an auto-generate with some built in intelligence.

Any ideas how I can make this happen?

All suggestions and advice will be appreciated.

Many Thanks
Warren
 
Seems that nobody else has a solution here either.

I have managed to upgrade to v8.2 and on of the features in v8.2 is that you are able to change column data types which resolves my problem.

I will create the DR database with an ID column as an INTEGER and then if ever we go into a DR situation, I will run a script to change the ID column to an auto generate identity and obviously restart the numbering on the column to keep records in sequence.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top