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



Oh yeah, %scanrpl() is awesome. I have a mailmerge app for AR letters where I used it extensively.

Once I gave it some fresh thought, this was a simple solution...

// chain to get the file name, column names, and descriptions

qtSUMFLD102 = cnQT + %trim(SUMFLD102) + cnQT;
qtSUMFLD202 = cnQT + %trim(SUMFLD202) + cnQT;
qtSUMTXT102 = cnQT + %trim(SUMTXT102) + cnQT;
qtSUMTXT202 = cnQT + %trim(SUMTXT202) + cnQT;

sqlStmt = 'select '
+ qtSUMFLD102 + ' , '
+ qtSUMFLD202 + ' , '
+ qtSUMTXT102 + ' , '
+ qtSUMTXT202 + ' , '
+ 'sum(' + SUMFLD102 + ') , '
+ 'sum(' + SUMFLD202 + ') , '
+ 'count(*) '
+ 'from '
+ FILNAM02;

Prepare, etc..... Fetch Into :dsSum;

EVAL DSSUM
FIELD1 OF DSSUM = 'ORIAMOUNT '
FIELD2 OF DSSUM = 'REMAMOUNT '
TEXT1 OF DSSUM = 'ORIGINAL AMOUNT '
TEXT2 OF DSSUM = 'REMAINING AMOUNT '
VALUE1 OF DSSUM = 0000000000200.00
VALUE2 OF DSSUM = 0000000000100.00
RCDCOUNT OF DSSUM = 1


Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power

 
 





From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of Alan Campin <alan0307d@xxxxxxxxx>
Sent: Friday, June 2, 2017 10:52 AM
To: Midrange Systems Technical Discussion
Subject: Re: Soft coding SQL based on parameter file
 
If you are on V7R1 or forward use %SccanRpl. Will make your life so much
easier.

Statement = 'Select <<FIELD1>>,
                    <<FIELD2>>
               From <<File>>
               Where <<FIELD3>> = Cast(? As Char(10))'

Statement = %ScanRpl('<<FIELD1>>', FieldName, Statement);

etc.

Especially handy for quotes

dcl-c QUOTE '''';

Statement = 'Select <<FIELD1>>,
                    <<FIELD2>>
               From <<File>>
               Where <<FIELD3>> = Cast(? As Char(10))' And
                     <<FIELD4>> = <<Q>>Y<<Q>>)'

Statement = %ScanRpl('<<Q>>',QUOTE: Statement);



On Fri, Jun 2, 2017 at 10:19 AM, Roger Harman <roger.harman@xxxxxxxxxxx>
wrote:

Thanks.  I did get it to work with dynamic SQL.  Just straightening out
the right mix of literals and data values to string together.

Short & Sweet to do what I want.

Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power







From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of
dlclark@xxxxxxxxxxxxxxxx <dlclark@xxxxxxxxxxxxxxxx>
Sent: Friday, June 2, 2017 8:21 AM
To: Midrange Systems Technical Discussion
Subject: Re: Soft coding SQL based on parameter file

         Just use VALUES ... INTO and dynamic SQL.  You just have to build
most of the SQL statement in a variable-length character variable.  You
can't use a parameter marker for the select columns or the table/view
names FROM which to get the data or the GROUP BY or ORDER BY clauses.  You
can use parameter markers for the WHERE clause if you want to.

Sincerely,

Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331



************************************************************
*********************************
This email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary
information. If you have received this message in error, please
immediately notify the sender and delete and destroy the message and all
copies. All unauthorized direct or indirect use or disclosure of this
message is strictly prohibited. No right to confidentiality or privilege
is waived or lost by any error in transmission.
************************************************************
*********************************
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l


MIDRANGE-L Info Page
lists.midrange.com
The topic of the list is Midrange Systems. This includes the IBM I, System i, iSeries, and AS/400 (S/34, S/36, & S/38 discussion is allowed, if anyone still has one ...



MIDRANGE-L Info Page
lists.midrange.com
The topic of the list is Midrange Systems. This includes the IBM I, System
i, iSeries, and AS/400 (S/34, S/36, & S/38 discussion is allowed, if anyone
still has one ...

or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


midrange.com -- MIDRANGE-L mailing list archive
archive.midrange.com
midrange.com MIDRANGE-L mailing list archive



midrange.com -- MIDRANGE-L mailing list archive
archive.midrange.com
midrange.com MIDRANGE-L mailing list archive


Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:  http://amzn.to/2dEadiD

http://g-ec2.images-amazon.com/images/G/01/social/api-share/amazon_logo_500500._V323939215_.png

Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more
amzn.to
Online shopping from the earth's biggest selection of books, magazines, music, DVDs, videos, electronics, computers, software, apparel & accessories, shoes, jewelry, tools & hardware, housewares, furniture, sporting goods, beauty & personal care, broadband & dsl, gourmet food & just about anything else.



Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books,
DVDs & more
amzn.to
Online shopping from the earth's biggest selection of books, magazines,
music, DVDs, videos, electronics, computers, software, apparel &
accessories, shoes, jewelry, tools & hardware, housewares, furniture,
sporting goods, beauty & personal care, broadband & dsl, gourmet food &
just about anything else.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


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.