> From: David Morris
> Joe,
> I agree that this is not a good place to use SQL, but for
> the same reason, OPNQRYF and a four line RPG program
> are just as bad. You can easily do what you describe using
> SQL and an RPG UDF or even SQL and an SQL UDF in
> a single pass. The problem is that it is not dynamic and will
> have to be rerun when data is changed in the file. I would
> consider moving the rank to another file and updating it from
> a short (but not four line) trigger written in RPG.
> Check out the message I posted earlier to see how you
> could construct and create that UDF.

Why are OPNQRYF and an RPG program bad, David?  The SQL statement was bad
because it has a lot of overhead and is difficult to understand.  OPNQRYF
and an RPG program, on the other hand, are very straightforward and perform
very well.

As to the UDF, why is a 100 line UDF (not counting comments) - which in turn
is used to generate a module, a service program and UDF function - a better
answer than a single-line OPNQRYF and a 4-line RPG program?  What if you
need a different ranking - say an alphabetical sequence number?  You need a
new UDF!  And you STILL have to write the SQL statement that uses the UDF.

RPG is an excellent language for doing database I/O.  Why people insist on
"getting away from it" is beyond my meager intellectual capabilities.  Maybe
it's "new-itis".  In the early part of my career, I was bitten by the
"newest is best" bug and every time I learned a new technique, I applied it
to every situation, whether it needed it or not.  But as I've gotten older
and lazier, I've learned that while you shouldn't use a hammer to screw in a
screw, it's still the best tool in the toolbelt for pounding in a nail.  In
fact, even though there are situations where a powered nailgun does the job
better, for many simple jobs, the old-fashioned claw hammer, as inelegant
and unsexy as it may be, is still the best tool for the job.

I dunno, but I think my 5-line, two-program solution beats your 100-line, 3
object technique any day of the week.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 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.