× 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 19-Aug-2016 15:27 -0700, Barbara Morris wrote:
On 8/19/2016 6:02 PM, CRPence wrote:
...
Yet I find that coding the following is just as conspicuous in
that regard; and for me, not at all problematic to change from
using purely RPGLE to using SQLRPLE to achieve that
simplification\conciseness:

exec sql
set :fld = max(:value1,:value2)
;
...

One possible downside to using SQL is that it doesn't support
expressions or named constants or complex qualified names. So
temporary variables would occasionally have to be set up prior to
using the max() or min() function.

Agreed that restrictions for host variables, to be used with the SQL, can be a pain.

But the expressions can be performed with the host variables coded in SQL expressions, and the data types need not be consistent, as long as they are compatible. And although I shown none here, they could even be coded in explicit data-type casting scalar functions or in the CAST expression, so as to avoid the integer result seen for the first expression. For example:

d msg s 45a
d max_Val s 9p02
d*
d cTen_03 c 10.03
d vTen_03 s 4p02 inz(10.03)
d*
d valDS ds
d valvc10 10a inz('544') varying
d vali4 10i00 inz( 50 )
d valc5 5a inz('201')
d valp5 5p01 inz( 20 )
d*

exec SQL
set :max_Val =
max( :valDS.valvc10 / :vali4 /* 10 vs 10.88 */
, :valDS.valc5 / :valp5 /* 10.05000000 */
/* , :cTen_03 <-- constants disallowed! */
, 10.03 /* <-- use literal instead.? */
, :vTen_03 /* <-- Or, use a variable */
)
;
// again, no error checking included
msg = 'max_Val=' + %editc(max_Val:'P') ;
dsply msg ;
// Expected output:
// DSPLY max_Val= 10.05



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.