Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using variable as part of table name

Status
Not open for further replies.

zalewski66

Programmer
Jul 29, 2002
4
0
0
US
I have a public variable called jobnumber which will store 4 digit number and I want to be able to create a table with the jobnumber as the first four characters followed by MSTR

so i want to end up with 9999MSRT as the table name.

How can I accomplish this ???

Thanks !!
John
 
You can do something like:

STORE ALLTRIM(STR(jobnumber)) + 'MSTR' TO MyTable

Now you can either create the table using:
CREATE TABLE (MyTable) ;
(Field1 C(10),;
Field2 C(25 ),;
Field3 D(8))
whatever the structure is, or:

USE MyMST
COPY STRUCTURE TO (MyTable)

One bad thing about creating tables with a name beginning with a number, is that whne you open them they default to a character alias such as A. You may want to consider modifying your naming convention to begin with a character:

Something like:
STORE 'MSTR' + ALLTRIM(STR(jobnumber)) TO MyTable

instead.

Dave S.
 
John,
if you use only one job at the same time (as I),
i recommend only number and same alias,
for example
job = padl(jobnumber,4,"0")
copy file job_patt.dbf to &job..dbf
use (job) alias job
,to better reference to table job...
Tesar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top