Joel, I typically specify source type = TXT for the sql code I
keep in source members for use with RUNSQLSTM
If you want multiple statements, separate using a semicolon.
Here is a simple example:
-- this is a comment
CREATE TABLE mylib/mytbl
( COL1 CHAR(04),
COL2 NUMERIC(5,0),
COL3 DECIMAL(11,5)
)
;
LABEL ON TABLE mylib/mytbl
IS 'test sql in source mbr'
;
LABEL ON COLUMN mylib/mytbl
( COL1 TEXT IS 'Character 4',
COL2 TEXT IS 'Numeric(5,0)',
COL3 TEXT IS 'Decimal(11,5)'
)
;
RUNSQLSTM SRCFILE(mylib/mysrc) SRCMBR(mytbl) COMMIT(*NONE)
If you have any errors, RUNSQLSTM will create a spool file
Hope this helps...
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Friday, May 11, 2012 1:02 PM
To: Midrange Systems Technical Discussion
Subject: easier SQL statements in CL
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)
I recall that others like to create a string with the MSG commands.
Is it possible to code the straight SQL statements with no tricks in a CL source member (like in the old punch-card days to suck in a few data records?) :)
Any method would be great if I can skip all the *tcats, and quotes mess.
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:
PGM
DCL &SQLCMD type(*CHAR) len(1000)
//start SQL
/*
create table qtemp/sqltemp1 (fld1 char(1) ---
fld2 char(1) |
fld2 char(1) |---- would like to run this nice readable SQL command in CL without quotes and tcat's
client numeric(6,0)) ___|
/*
RUNSQL
Thanks!
______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs Skyscan service.
For more information please visit
http://www.symanteccloud.com ______________________________________________________________________
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.