That looks pretty good - is this method widely used in the /400 community for building SQL command strings?
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Monday, April 02, 2012 10:45 AM
Subject: Re: Is there a better way to run SQL in a CL pgm?
On 01-Apr-2012 17:41 , Jack Callahan wrote:
Have you considered using RTVMSG? Used to use this technique to setupIf using that technique, surely the use of *QTDCHAR data type for the
the QRYSLT parameter of the OPNQRYF command .
Tweak your message to as needed to get the parameter lengths and
MSG('SQL STRING for my CL program.')
SET LG_ERRMSG=''&1'' LG_ERPATH=''&2''
WHERE LG_DATE=&3 AND LG_TIME=&4 AND LG_ID=''&5''
AND LG_SEQ=''&6'' AND LG_CLIENT=''&7''')
FMT((*CHAR 7) (*CHAR 10) (*CHAR 10) (*CHAR 10)
(*CHAR 10) (*CHAR 10) (*CHAR 10))
message data fields representing quoted character string literals would
be better, to also avoid the escaped apostrophes in the ADDMSGD?
SET LG_ERRMSG=&1, LG_ERPATH=&2 ...
FMT((*QTDCHAR 7) (*QTDCHAR 10) ...