Jerry, I think I understand now.
There is no way to point CREATE TABLE statement to a DDS source member.
You can have source members that do CREATE TABLE and then point RUNSQLSTM to
it and create tables (files) that way, but that method does not satisfy your
requirement as you want to be able to reuse that source to create another
table and RUNSQLSTM does not allow dynamic file naming.
You can accomplish what you want via QMQRYs (as someone already pointed that
out). For example, lets say you have a source physical file called
QQMQRYSRC. In it you create a source member (similar to creating a new DDS
source member), let's call it GENERICTBL. In that source member you have
your CREATE TABLE statement, i.e.:
CREATE TABLE &library/&file (F1 INTEGER NOT NULL WITH DEFAULT)
Then you create your QMQRY object (this is a one time step only):
CRTQMQRY QMQRY(myLib/GENERICTBL) SRCFILE(mySrcLib/QQMQRYSRC)
Now you can use that QMQRY object any time you want to create the table with
exact same format, passing in the library and file parameters as you please,
i.e.:
STRQMQRY QMQRY(myLib/GENERICTBL) NAMING(*SYS) SETVAR((LIBRARY fileLib)
(FILE newFileX))
All that said, I think it's cleaner to create a "field reference file" and
then use CREATE TABLE AS ... and let system figure out all the formatting
etc., but that's just me :)
HTH, Elvis
Celebrating 10-Years of SQL Performance Excellence
http://centerfieldtechnology.com/training.asp
-----Original Message-----
Subject: Re: SQL DDL Create Table Names
Elvis,
Thanks for the link. Though I hadn't checked that one out ahead of
time, I had gone to a couple of others and some printed (gasp!) material
beforehand.
It may be that I am either not understanding the response or that I
didn't make myself clear. Which, in either case, is my fault. So let's
see if I can do at least a little better.
We can give a DDS source member any name, FILEJ, for example. On the
CRTPF or CHGPF commands there is a FILE parameter and the value used,
JFILE, for example, points to (or creates) a specific file named JFILE
based upon the source member (FILEJ) provided. I.e., while usually the
DDS source member and physical file have the same names, it ain't
necessary; the name of the file to be created (or changed) is not
inherent inside the DDS source member.
Now, if I understood your example and the other reading, "newTable" is
the actual name of the table that will be created. There is no way that
I have seen/found to use this same source member to create "newTableX".
Or is there? If not, I'll have to stick with DDS for these mirror-image
tables and use SQL for the unique tables (new or old).
* Jerry C. Adams
As an Amazon Associate we earn from qualifying purchases.