Problem in Insert or Update in DB adapter
905784Jul 5 2012 — edited Jul 5 2012Hi All,
I wanted to insert or update the records into multiple tables in single instance.
Problem is there is a primary key across all 3 tables but that will generate in auto sequence for every new insertion of records. (say, 1,2,3,4, for every new insertion).
There is one more field common across all the 3 tables but that is not a primary key which actually has the unique records everytime, I should use this field in order to avoid duplication.
When I used Insert or Update(merge operation), then it is validating with primary key which is autogenerating in this case.
Hence, I decided to go with Pure SQL but could not find right example to do that.
I got this query
if table t has a row exists that has key X:
update t set mystuff... where mykey=X
else
insert into t mystuff...
But how it should be converted to real case.
Please can anyone suggest how to perform this.
Thanks