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



On 10/17/2023 10:40 AM, Greg Wilburn wrote:
I have an older procedure that reads records within a file to create a character string from one of the fields (RFDTA) in the file. The resulting string is placed into various data structures, so the "position" is important.

-snip-

This positional/unit record requirement might be the first thing to reconsider. SQL isn't very good at emulating unit record applications.

I created an SQL statement that works only when all sequence numbers exist.
SELECT rfslc, LISTAGG(RFDTA) WITHIN GROUP(ORDER BY RFCAT, RFSLC, RFSQ2) AS RFDATA
FROM REFERRF
WHERE rfcat=:incat and rfslc=:inslc
GROUP BY RFCAT, RFSLC

Is there a way with SQL to accomplish the same thing without having to read a row at a time?


In my opinion, one of the immense powers of our platform is the ability to wrap RPG code into an SQL stored procedure. I myself would take this option. If you worry about duplicating code (who doesn't?), consider how to refactor the RPG into a subprocedure. Put that into a service program, then both the existing RPG and the new SQL function/procedure can reuse that single block of logic, and always return the same output for the same input.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.