On 14-Jun-2015 14:32 -0600, Jack Tucky wrote:
I am running a statement like this for multiple files.

How can I eliminate copying records that already exist in the
destination file? There are additional key fields besides SHP.

INSERT INTO INVTO/skusum
SELECT *
FROM INVFROM/skusum
WHERE shp = 12345


Untested, but I believe syntactically correct to achieve what is expressed [where the additional key fields are ky2, ..., kyN]:

INSERT INTO INVTO/skusum T
SELECT *
FROM INVFROM/skusum F
WHERE F.shp = 12345
and not exists
( select '1'
from INVTO/skusum X
where X.shp = F.shp /* or same literal 12345 */
and X.ky2 = F.ky2
...
and X.kyN = F.kyN
)

The MERGE statement or the Copy File (CPYF) might serve as reasonable alternatives, depending on the specific requirements.


This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2026 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.