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



David, I agree with your points.

RPG has, in my experience, unique capabilities that result in minimal code
for many solutions.

In your example, is there any reason OPNQRYF could not have been replaced
with SQL (maybe a QM Query),
and, therefore, eliminated the need to "simulate select distinct"
with an additional call ?




David FOXWELL <David.FOXWELL@xxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/20/2011 01:51 AM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
cc

Subject
replace opnqryf with sql






This is often the advice, but it seems easier to say than do.

I was just given a small program to write where, in the good 'ol days, I'd
have done an opnqryf followed by a client file read with the rpg cycle and
use the calculation specs beginning or end to treat the client once only
if it occurs multiple times in the file.

As I can no longer write opnqryf that complex without looking it up, I
plunged straight into the rpgsqle solution :

Declare result set DS

Dynamically prepare a cursor
Declare cursor
Open cursor

Then logic to Fetch

Manage sql errors after each operation.

The query was a select distinct on one file only using a date field that
was returned from a subprocedure.

The CLP that calls the rpg is now very clear, but the rpg is not as simple
as it would have been had I used the cycle.
Also during development, I had to add another field to the result set. As
my Fetch was in a subroutine and it was returning its results as
parameters, this meant changing the DS, the parameters, the prototype, the
callp and the cursor. With RLA, the extra field would already have been
available.

The non sql solution would have been :
CALLP getDateParameter
OPNQRYF using dateParameter
CALL RPG using cycle to 'simulate' select distinct.

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.