On 11 May 2012 12:01, Stone, Joel wrote:
There MUST be a better method of coding SQL in a CL source member.


In the example below, is there a simple way to copy everything
between the "/*" to a source member and run that?

Or any other method to keep the CL together with the SQL commands in
the same member - without using quotes or tcat's.

Something like the following; i.e. would like to run this nice
readable SQL command in CL without the quotes and tcat's:

DCL &SQLCMD type(*CHAR) len(1000)

//start SQL

create table qtemp/sqltemp1
(fld1 char(1)
,fld2 char(1)
,fld2 char(1)
,client numeric(6,0)



With the above, use a batch stream with //DATA commands to define those source rows as data for the inline data file. Or [write and] use a CL interpreter [without a //BCHJOB] preferably with some support included, to generate temporary source members for embedded //DATA commands.

Of course just switching to REXX would be simpler than either of those.

Or perhaps create the program from the output of a source pre-processor instead of that source directly. Then the SQL can be defined as rows of data like shown above, even in a separate /INCLUDE member, or perhaps defined similarly but using macroinstructions to identify and possibly assign the statement to an identifier which could be referenced on later commands. A pre-processor could generate the rows as strings using line continuation while handling apostrophes and concatenations as necessary; i.e. would still composed as a CHGVAR in the eventual source, but via a program rather than the programmer. Or it could even be as sophisticated as an effective SQL pre-compiler. The original pre-processor [macro]instructions can be omitted entirely from the eventual source that will be compiled, or could be wrapped inside of paired comments either on successive lines or with.... line continuation ;-)

Regards, Chuck

This thread ...

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].