×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Thanks to all who responded. My main goal is to make the program to run faster.
I tested with the code below and RPG and CL as well. RPG seems to be taking less time , quite nt sure why.
I am under impression that CPYF and SQL do some blocking by default and they dont use maximum block size, is it true?
The number of records that is getting written(/copied) are nearly 100,000 and file contains more than a million.

Thanks,

Donna.


--- On Tue, 9/30/08, Lim Hock-Chai <Lim.Hock-Chai@xxxxxxxxxxxxxxx> wrote:

From: Lim Hock-Chai <Lim.Hock-Chai@xxxxxxxxxxxxxxx>
Subject: Re: Re writing CL in RPG
To: rpg400-l@xxxxxxxxxxxx
Date: Tuesday, September 30, 2008, 10:23 AM
You could also try using SQLRPGLE:

// copy data from ABBC.FILE to XYZ.MONY
// Note: This only copy F records or ID/name/acct records
// that exist in GEUKACT into XYZ.Mony
exec sql
insert into "XYZ.MONY" a
(select * from "ABBC.FILE" b
where
b.ID = 'F' or
exists
(select 1 from GEUKACT c
b.ID=c.ID and b.name=c.name and
b.acct=c.acct
)
);

// copy data from AFILE to XYZPOSREC
// Note: This only copy F records or ID/name/acct records
// that exist in GEUKACT into XYZPOSREC
exec sql
insert into "XYZPOSREC" a
(select * from "AFILE" b
where
b.ID = 'F' or
exists
(select 1 from GEUKACT c
b.ID=c.ID and b.name=c.name and
b.acct=c.acct
)
);


Note: I've not tested or run thru SQL syntax check.


"donna lester" <donna_lester_ny@xxxxxxxxx>
wrote in message
news:<mailman.14334.1222728629.2545.rpg400-l@xxxxxxxxxxxx>...
Hi
Below is my code. I am trying to replace copy commands
program by
writing RPGLE.
Is this a good design , will this run faster? I would
like to know
your opinions and suggestions.
Thank you for your time. The number of records in
AFILE usually more
than a million.



LOOP: RCVF

MONMSG MSGID(CPF0864) EXEC(GOTO
CMDLBL(END))



CPYF FROMFILE(*LIBL/ABC.FILE) +

TOFILE(*LIBL/XYZ.MONY)
MBROPT(*ADD) +
INCREL((*IF MID *EQ &YID)
(*AND +
MNAME *EQ &YNAME) (*AND
MACCT *EQ &YACCT))
CPYF FROMFILE(*LIBL/AFILE) +

TOFILE(*LIBL/BFILE)
MBROPT(*ADD) +
INCREL((*IF PID *EQ &YID)
(*AND +
PNAME *EQ &YNAME) (*AND
PACCT *EQ &YACCT))


GOTO CMDLBL(LOOP)



END: CPYF FROMFILE(*LIBL/ABC.FILE) +

TOFILE(*LIBL/XYZ.MONY)
MBROPT(*ADD) +
INCREL((*IF MID *EQ F))

TOFILE(*LIBL/XYZ.MONY)
MBROPT(*ADD) +
INCREL((*IF MID *EQ F))

CPYF FROMFILE(*LIBL/AFILE) +

TOFILE(*LIBL/BFILE)
MBROPT(*ADD) +
INCREL((*IF PID *EQ F))



=========================
* Copy data from ABCFILE by ID, NAME, Acct

C k_idnamacc Setll ABCFILE

C Read ABCFILE

C DoW Not %Eof(ABCFILE) and
MID = YID
C and MNAME = YNAME and
MACCT = YAcct
C Write XYZMNYREC



C Read ABCFILE

C EndDo



* copy data from AFILE by ID, NAME, Acct

C k_idnamacc Setll AFILE

C Read AFILE

C DoW Not %Eof(AFILE) and PID
= YID
C and PNAME = YNAME and
PACCT = YAcct
C Write XYZPOSREC

C Read AFILE

C EndDo

*

C Read GEUKACT

C Enddo

*

* Copy ABCFILE records for ID F

C 'F' Setll ABCFILE

C Read ABCFILE

C DoW Not %Eof(ABCFILE) and
MID = 'F'

C Write XYZMNYREC

C Read ABCFILE

C EndDo

*

* Copy AFILE records for ID F

C 'F' Setll AFILE

C Read AFILE

C DoW Not %Eof(AFILE) and PID
= 'F'
C Write XYZPOSREC

C Read AFILE

C EndDo

*

C Eval *inlr = *on




C *InzSr Begsr



C k_idnamacc KList

C KFld YID

C KFld YNAME

C KFld YACCT



C Endsr


Donna.



--
This is the RPG programming on the AS400 / iSeries
(RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

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.