MIDRANGE dot COM Mailing List Archive

Home » MIDRANGE-L » December 2013

Re: File Comparision


Thanks, Chuck, Narayanan

On Wed, Dec 4, 2013 at 11:47 PM, CRPence <CRPbottle@xxxxxxxxx> wrote:

On 04-Dec-2013 19:10 -0800, Vinay Gavankar wrote:

I have 2 files, FILEA and FILEB, which have exactly same format,
about 20 fields each and the total length of the record is less than
200 bytes.

FILEB is a subset of FILEA.

What is the simplest way of getting a file with records in FILEA not
present in FILEB?

Working on a development box, so I am free to create temporary files
from these 2, as the number of records in these files is not very

I may have to repeat this a few times so trying to figure the
simplest solution.

As UNION is a [row] set operation to combine rows, similarly the
INTERSECT but to obtain matching rows, and the EXCEPT is another to show
the difference.


IBM i 7.1 Information Center -> Database -> Programming -> SQL
programming -> Data manipulation language -> Retrieving data using the
SELECT statement

_Using the EXCEPT keyword_
"The EXCEPT keyword returns the result set of the first subselect minus
any matching rows from the second subselect.

So for example with the given assumptions, a similar scenario:

create table qtemp/filea (a char, d dec)
insert into qtemp/filea values
(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)
create table qtemp/fileb (a char, d dec)
insert into qtemp/fileb values
(1, 1), (2, 2), (5, 5)
select * from qtemp/filea
select * from qtemp/fileb
; -- effective report from above query follows:
3 3
4 4
**** end of data ****

Regards, Chuck
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact