On 19-Aug-2016 03:24 -0700, Vernon Hamberg wrote:
On 8/19/2016 3:31 AM, Brian Parkins wrote:
On 18-Aug-2016 15:00 -0700, Vernon Hamberg wrote:
Every system also has SQL CLI - granted, not so simple as
embedded SQL, but it works well.
Every system also has the RUNSQL CL command - maybe another
approach?
Well, to avoid accusations of hyperbole, at least since some TR on
IBM i 7.1
I am not sure that RUNSQL would work - not Query Management queries
- because neither returns a value directly to a program. That is, IF
a return value is needed.
Actually, for those few who remain willing and able to consume beyond
140-bytes at a time, my post in response to "And if you don’t have SQL?"
showed _an actual example_ using RUNSQL as the SQL interpreter; as just
_one_ way to obtain the effect of MAX of values from the SQL, without
having the 57xxST1 SQL product installed to enable embedded SQL. The
/return value/ was via a database file, of which the RPG [and typical
coder] is able to obtain\consume quite easily:
[
http://archive.midrange.com/rpg400-l/201608/msg00206.html] <-- best
viewed using the fixed-font {A} button.
FWiW, since likely nobody would ever waste their time trying out the
code snippet to actually _see_ the implementation functioning, I will
reveal that sadly, the DB2 for i 7.1 seems unfit\incapable to handle
what I coded, so the SQL shown, probably would have to change [e.g. to
use the MAX scalar instead of row-values and MAX aggregate] to see the
code function as alluded.
But I just thought about SQL stored procedures - I haven't looked at
prerequisites for that.
The CALL to a stored procedure has to be done with the SQL CALL, so
EXEC SQL would need to be coded; thus the SQL pre-processor would need
to convert that EXEC SQL into RPG.
Even so, the same issue exists with implementing a stored procedure
that can generically effect a MAX( arg1, arg2, ... argN ); mainly, how
to pass those arguments in a way that does not become overly difficult
to code and maintain, such that just writing one's own specific routine
in the original host language could be the most appropriate choice
[whilst waiting indefinitely for the capability to appear in the host
language itself, possibly arriving solely due to the RFE, and if so,
then likely only appearing even farther into the future than if
something already in the pipeline].
As an Amazon Associate we earn from qualifying purchases.