× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

How about using SQL to access the data, with cursors and fetches.
In this way you will not have to worry about tens of logical files.

But you have to care about the optimal access paths (stored either in keyed
DDS logical files or SQL indexes).
If your files only consist of a few 1,000 rows a table scan may be faster
than using an access path.
But in real world you have files with several millions of rows and there it
makes quite a difference if a table scan must be used to find a single row
or the row can be accessed directly through an access path.

Or even nicer with prepared sql's.
Dynamic SQL in RPG is less performant compared with static SQL, because at
runtime first the string must be converted into an executable SQL statement
(including syntax checking). After an access plan must be built by scatch(at
least with CQE, SQE may validate an existing access plan stored in the SQE
plan cache). With static SQL both steps are already performed at compile
time. Also, with static SQL the access plan get stored in the program object
(PRTSQLINF will show it) and can be validated and eventually actualized at
runtime.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Mihai CARSTOIU
Gesendet: Thursday, December 13, 2007 00:48
An: RPG programming on the AS400 / iSeries
Betreff: Re: A Question Of Technique


Hello,
How about using SQL to access the data, with cursors and fetches. In this
way you will not have to worry about tens of logical files. Or even nicer
with prepared sql's.

Best regards,
Mihai

http://rpgCRUD.ro


On 12/12/07, Kelley <kshaddrick@xxxxxxxxxxxxxxxx> wrote:

Wilt, Steve...

Thanks for the input. Do you know of any examples of this kind of
thing on the web?

Kelley

----- Original Message -----

From: "Wilt, Charles" <WiltC@xxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, December 12, 2007 9:53 AM
Subject: RE: A Question Of Technique


Kelly,

You don't "exit" a service program...mainly because you never enter
it. <grin>

Instead, the service program contains one or more individual
procedures. Those procedures can be called from outside (or inside
:) the service program, ie. From your UI program.

You have two options for returning data from a procedure.
1) In an parameter variable
2) As a returned value.

In either case, the data can be a single variable or a DS.

You'll see many of examples of procedures that output/return the
contents
of the entire record using a
DS defined from the external file. However, I'd argue against doing
it that way. When you need to change the file, you have to
recompile the world. The reality is few program really need the
entire record, mainly the just CRUD programs. The rest only need
certain parts of the data in the file.

Another technique is to have Getters/Setters that set/return
individual fields. Again, I'd argue against doing it this way.
Mostly because you end up duplicating the business logic related to
the fields. In addition, it's more work when you need data out of
more than one field.

Instead, consider having procedures that return the data in a
business appropriate way. For instance, a GetDescriptiveInfo() that
returns item#, name, size, and other often used together fields. In
addition, if you've currently got Yes/No type flag fields, don't use a
GetFlagFld() type procedure to
return the actual value of the field. Instead, use a IsItemSomething()
procedure. This way, if you
ever need to change the business logic behind the decision, you only
need
to change it in one place.

I've gone so far as to have a GetSimpleList() procedure that takes
as input, the number of records at a time you want and an empty DS
of the appropriate size to fill; which I can call from multiple
subfile programs, either 5250 or web based.

HTH,
Charles


--
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-2024 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.