If the source table is defined with REUSEDLT(*NO) or rows are never deleted from the source table, you might be able to rely on capturing the RRN for the last row read from the source table and storing it as lastRRN. On subsequent runs, do a select where RRN(x) > lastRRN. Don't know if that will require a table scan through 6M records or Db2 can go directly to lastRRN + 1 to start. You might also need to ORDER BY RRN(x) if sequence matters.
- Dan Bale
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jim Oberholtzer
Sent: Tuesday, September 23, 2025 5:54 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Extract new rows only from a table with SQL to SQL server
The current process running has an SQL server using ODBC running a query against a IBM i table with 6 million rows (table scan, no selection criteria) and updating a SQL server table every night.
Right now, the process is a refresh of the 6 million rows on SQL server. In reality we only need the newest rows since the last run. Ordinarily I would just use a timestamp on the table to pull rows since a specific time, but this table does not have a timestamp on it (JDE supplied table so I cannot modify it)
Is there a way we can use SQL to get only the newest rows on the table? (Triggers are not available for the same reason I can't modify the table)
My guess is no, without a timestamp we cannot, but hopefully someone will have an enlightened answer.
Might temporal tables play in this scenario?
*** CONFIDENTIALITY NOTICE: The information contained in this communication may be confidential, and is intended only for the use of the recipients named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender. ***
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.