I have a table I created as a temporal table using a command as follows:

create table darren/tstp
(prod char(35) not null with default,
desc char(50) not null with default,
ChgUsr varchar(18) implicitly hidden generated always as (USER),
Start_TS timestamp(12) implicitly hidden not null generated always as row begin,
End_TS timestamp(12) implicitly hidden not null generated always as row end,
TS_ID timestamp(12) implicitly hidden generated always as transaction start id,
period system_time (start_ts, end_ts)


If I run an SQL MERGE similar to the following, where the QTEMP table has the same data as the target table, I get a history table record every time the merge is run. Is there an option I'm missing to basically say, don't update the table if none of the fields are different? I realize I could perhaps write a compare for each field, but sometimes a file might have hundreds of fields, so, I was hoping for something a little less laborious. An SQL update does the same thing (a history record for every non-update), but, I looked at the MERGE, hoping it was a little more intelligent, so, if there is something different that could be done with the UPDATE, that might be interesting too.

merge into darren/tstp a using
(select * from QTEMP/tstp) b
on a.PROD=b.PROD
when matched then update set
when not matched then insert
b. prod,
b. desc)

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.