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



Why not wapping the complexity of the SQL statements in SQL Views and then use the (different) views where ever you need them.
... so you only have to add a few where conditions and may be an order by.
... and this can even be done dynamically.

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!"
„Train people well enough so they can leave, treat them well enough so they don't want to.“ (Richard Branson)


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Carel
Sent: Samstag, 9. Mai 2020 22:48
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Multiple INCLUDE statements in SQLRPGLE

Why not have the SQL statmements in a source file, read through that file to build the statement and then do a EXEC IMMEDIATE?


Op 9-5-2020 om 21:52 schreef Brian Parkins:
You say, "The goal is to move common code out of the application
source and into copy books for ease of development and maintenance."

May I humbly suggest that your (laudable) goal precludes the use of
copybooks in this way. In fact, you may end up with something more
difficult to maintain.

Have you considered wrapping your common code in procedures and
packaging these in a service program?

Brian.

On 09/05/2020 07:17, Reeve wrote:
I'm trying to stack multiple INCLUDE's to generate static SQL. The
goal is
to move common code out of the application source and into copy books
for
ease of development and maintenance. I have a need to include a JOIN in
some cases, and while I could simply have two versions of a single
consolidated copy book (one with the join and one without), that
solution
doesn't appeal to me.

This is the first copy book:
EXEC SQL
SELECT cmcust INTO :cmcust FROM arp001

and this is the second:
WHERE cmstat = 'A'

and this is the third:
AND CMCLS = 'R'

...and there will be additional selections.

Here's what the code might look like:
/include qcpysrc,testcopy1
JOIN arp002 ON cmcust = nmcust
/include qcpysrc,testcopy2
/include qcpysrc,testcopy3
and cmcls = 'R' and nmtype = '2';

The source out of the preprocessor includes an /END-FREE and the
compiler
tags the "-" in column 11 as an error even when the source member
includes
a /FREE in it. The first SQL line isn't terminated so the
preprocessor is
likely not looking for an /END-FREE.
Position 11 Token - was not valid. Valid tokens: FOR USE

When I've added a /FREE statement to these source members, the error
still
appears. I've tried COPY as well; still getting errors in the
preprocessor
output. Using RPGPPOPT(*LVL2) and V7R3M0.

I'll be grateful for any ideas!

Stay safe and stay healthy.

-reeve



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.