|
<<SNIP>>
If the command being used does not provide such support, then create
an interface that enables something similar. It does not have to be
a RUNSQL command itself nor even implement a SETVAR parameter which
is a bit complex; and when I did, used IBM-only command parameter
features. It could use the effective DS capability of CL variables
where each variable includes definitional attributes preceding its
data. Or it could use something like data area(s) or environment
variables to define both the variable name and its value from the CL
variable, then invoke a command that returns the updated statement.
For example:
<code>
CHGVAR &SQLCMD VALUE(' +
/* ---------- nice SQL ---------- */ +
INSERT INTO LGFILE +
( LG_CLIENT, LG_SEQ, LG_DATE, LG_TIME +
, LG_DIR, LG_ID, LG_MODE, LG_NRECS +
) +
VALUES +
( :P_CLIENT, :P_SEQ, +
/* ( ":P_CLIENT", :P_SEQ, */ +
, :CUR_YYYYMD, :CUR_HHMMSS +
, :P_DIR, :P_ID, :MODE, :P_NRECS +
) +
/* ------------------------------ */ +
')
ADDENVVAR ENVVAR(P_CLIENT) VALUE(&P_CLIENT)
ADDENVVAR ENVVAR(P_SEQ) VALUE(&P_SEQ)
...
ADDENVVAR ENVVAR(P_NRECS) VALUE(&P_NRECS)
REWRITESQL INPSTMT(&SQLCMD) RTNSTMT(&NEWSQLSTMT)
/* The CPP of REWRITESQL replaces each :EnvVar with the */
/* VALUE() from the environment variable named EnvVar */
/* A naming convention or something else could define */
/* rules for what to delimit; e.g. ":EnvVar" could be */
/* replaced by ''ValueOfEnvVar'', even escaping of the */
/* apostrophes, so a P_CLIENT="O'Connor" correctly gets */
/* written into the overall SQL statement string as */
/* 'INSERT ... VALUES( ''O''''Connor'', ...)' */
RUNSQL &NEWSQLSTMT
</code>
As an Amazon Associate we earn from qualifying purchases.
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.