Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining two tables in a logical file

Status
Not open for further replies.

ndevriendt

Programmer
Jan 8, 2002
74
BE
Hello,

In SQL there is an UNION instruction where it is
possible to combine two queries with the same
record structure, and make a sort on the result
of this combination.

Is this also possible in a logical file ?

I haven the following query

select donrdo,patndo,udnrud as avwdo,dbdtud as dbdt, dbhrud as dbhr,
dedtud as dedt, dehrud as dehr
from burgud join bdosdo on donrdo = donrud
where patndo = 80850
union
select donrdo,patndo,sdnrsd as avwdo,dbdtsd as dbdt, dbhrsd as dbhr,
dedtsd as dedt, dehrsd as dehr
from bsocsd join bdosdo on donrdo = donrsd
where patndo = 80850
order by dbdt desc, dbhr desc


When I run this query, I've the result I want to have,
and that's all the records from table BURGUD and BSOCSD
together being sorted on DBDT and DBHR

I've tried to make an logical file as following
A R BURGUDR1 PFILE(BURGUD)
A DLKDUD
A DONRUD
A PATNUD
A UDNRUD
A DBDTUD
A DBHRUD
A DEDTUD
A DEHRUD
A K DBDTUD
A K DBHRUD
A R BSOCSDR1 PFILE(BSOCSD)
A DLKDSD
A DONRSD
A PATNSD
A SDNRSD
A DBDTSD
A DBHRSD
A DEDTSD
A DEHRSD
A K DBDTSD
A K DBHRSD

The problem here is that I can not say select * from logicalfilename
because he's telling me that there is more than one classification, and
I suppose that the records being sorted seperately on the two tables
and not at the combination of the two tables.

Thanks for your time and answer

Devriendt Nico
 
Check out Join Files (which is a type of logical file).

RedMage1967
IBM Certifed - RPG IV Progammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top