× 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 11 May 2012 12:01, Stone, Joel wrote:
There MUST be a better method of coding SQL in a CL source member.

Here is what an SQL stmt might look like that I created today:

PGM
DCL &SQLCMD type(*CHAR) len(1000)
chgvar &sqlCmd ('create table qtemp/sqltemp1' +
*tcat ' (fld1 char(1),' +
*tcat ' fld2 char(1),' +
*tcat ' fld3 char(1),' +
*tcat ' clientN numeric(6,0))')

RUNSQL(&sqlCmd)

<<SNIP>>

What is with all the *TCAT and extra apostrophes? Just use standard line continuation to allow the literal\constant string to span lines:

chgvar &sqlCmd ( +
'create table qtemp/sqltemp1 +
(fld1 char(1) +
,fld2 char(1) +
,fld3 char(1) +
,clientN numeric(6,0))' )

Or move the line continuation characters way to the right, optionally adding blank lines:

chgvar &sqlCmd (' +
+
create table qtemp/sqltemp1 +
(fld1 char(1) +
,fld2 char(1) +
,fld3 char(1) +
,clientN numeric(6,0)) +
+
' )

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.