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



Per IBM...

As of a few years ago, dynamic SQL isn't something to be afraid of
performance wise compared to static.

Mostly that's in the context of complex multi-part WHERE clauses where only
certain parts are evaluated depending on the flags.

I'm not a big fan of copy & paste and make a slight change. Much harder on
the guy maintaining it...

Oh wait, I have to change it here, and here....

Charles



On Fri, Sep 1, 2023 at 3:11 PM Dave <dfx1@xxxxxxxxxxxxxx> wrote:

Sorry, I wasn't at all clear and have now changed to the RPG list as
suggested by David

Program source is SQLRPGLE
Depending on criteria provided by a user entry program, I only need to (at
the moment) execute the same SQL statement but with different GROUP BY
clauses depending on what the user enters.

So I'd have one common select statement (which is quite complicated, I used
the CTE because I found it easier to read) and a certain number of
different GROUP BY clauses :
eg,

Select columns from file
Group by a

Select columns from file
Group by a, b

Select columns from file
Group by c

I'm thinking I'd be better off copying and pasting the same code rather
than building the statement at run time.

Thanks






On Fri, 1 Sept 2023 at 15:08, Dave <dfx1@xxxxxxxxxxxxxx> wrote:

Hi,



I have an RPGSQLE programme and I want to code several similar
statements.



They have a common WITH expression and only a difference in a GROUP BY
clause :



Exec sql

With t as (

SELECT etc with the same host
variables

)

SELECT etc

FROM t

GROUP BY (clause1 or clause2 ….)

End-exec



What is the best way to code this ? I seem to remember that having
several
copies of the statements instead of building them during run time is
actually more efficient.





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

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



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.