Converting a CL w/ Query/400 and CPYF to an SQL
We have this SQL it passed Crystal Reports but it is not returing any
'PAL' rows. The orig Query/400 is pretty simple:
It's a matched Join between ICLOCMLM and ICBLDTIR; joining on these:
T01.LMLOC1 EQ T02.IRLOC1
T01.LMLOC2 EQ T02.IRLOC2
T01.LMLOC3 EQ T02.IRLOC3
selects records: T01.LMLTPC LIST 'PAL' 'RAK'
sorts: rty A/D Field
10 A T01.LMLOC1
20 A T01.LMLOC2
30 A T01.LMLOC3 and creates an output file: BLDPALQ.
then this file gets added after the BAL file is added, giving us the
records we need, but for some reason in this SQL the PAL records are not
being added. only the RAK. IOW, the Query/400 and that CPYF are doing what
we need, but not this SQL.
CPYF FROMFILE(ASTDTA/ICBALMIE) +
TOFILE(ASTCCDTA/ACBALMPK) +
MBROPT(*REPLACE) FMTOPT(*MAP *DROP)
MONMSG CPF0000
*/
CPYF FROMFILE(TEMPLIB/BLDPALQ) +
TOFILE(ASTCCDTA/ACBALMPK) +
MBROPT(*ADD) FMTOPT(*MAP *DROP)
MONMSG CPF0000
SELECT LMLTPC, COALESCE(IRLOC1,'') as IRLOC1, COALESCE(IRLOC2,'') as
IRLOC2, COALESCE(IRLOC3,'') as IRLOC3, IRPRT#, IRQOH#, IRWHS#, '' as
IEPRT#, '.00' as IEQOH#, '' as IELOC1, '' as IELOC2, '' as IELOC3, '' as
IEWHS# FROM ASTDTA.ICLOCMLM mlm left join ASTDTA.ICBLDTIR tir on
mlm.LMLOC1 = tir.IRLOC1 and mlm.LMLOC2 = tir.IRLOC2 and mlm.LMLOC3 =
tir.IRLOC3 where LMLTPC in ('PAL', 'RAK')
UNION ALL
SELECT
' ' as LMLTPC, ' ' as IRLOC1, ' ' as IRLOC2, ' ' as IRLOC3, '' as IRPRT#,
'.00' as IRQOH#, '' as IRWHS#, IEPRT#, IEQOH#, IELOC1, IELOC2, IELOC3,
IEWHS# FROM ASTDTA.ICBALMIE
No comments:
Post a Comment