dbTalk Databases Forums  

Incrementing table name

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Incrementing table name in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
LawyerKill
 
Posts: n/a

Default Incrementing table name - 01-03-2004 , 07:22 AM






LK

Thanks to Mike and a few others here I'm almost done with my project, I have
one big problem left and maybe someone can give me some ideas on how I can do
what I need to do.

I need to create tables in increments, let me try to explain. I need to create
a table, let's call it, 'Market'.

Create Table Market;
(dstock c(4))

Now I need to select something from another table and insert it into table,
'Market'

Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market

Now I need to increment, 'Market' to maybe, 'Market01'. and save it, then
delete the original Market table, and start over again, each time incrementing
the tables name and saving it, so I would have Market01, Market02, Market03
etc.. I need to do this within the program and be automatic. If there was some
way I could change the Create table command maybe to increment at that point,
somelike this;

Create Table Market;
(dstock c(4))
Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market

Change Market somehow to Market 01 and run the program again this time save it
as Market02 etc..

Reply With Quote
  #2  
Old   
LawyerKill
 
Posts: n/a

Default Re: Incrementing table name - 01-03-2004 , 07:32 AM






LK

Oh it somehow I could change the name in the create table commant I would not
have to try and delete the original market, something like this;

Create Table Market;
(dstock c(4))
Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market

run program again;

Create Table Market01;
(dstock c(4))
Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market01

But somehow you would have to save the last Market name and it can't be in a
m,emory variable because you would lose it when you finished running the
program and started it again.

Reply With Quote
  #3  
Old   
Josh Assing
 
Posts: n/a

Default Re: Incrementing table name - 01-03-2004 , 03:24 PM



Something like:

LOCAL lcMarket
LOCAL ARRAY laMarkets[1]

ADIR(laMarkets,"Market??.dbf")

lnLast = VAL(RIGHT(JUSTSTEM(laMarkets[ALEN(laMarkets,1),1]),2))+1

lcMarket = "Market"+TRANSFORM(lnLast,"@L 99")

CREATE TABLE "&lcMarket" (;
dstock c(4))

IF USED("MarketXX")
USE IN MarketXX
endif

USE "&lcMarket" ALIAS MarketXX


On 03 Jan 2004 13:32:44 GMT, lawyerkill (AT) aol (DOT) com (LawyerKill) wrote:

Quote:
LK

Oh it somehow I could change the name in the create table commant I would not
have to try and delete the original market, something like this;

Create Table Market;
(dstock c(4))
Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market

run program again;

Create Table Market01;
(dstock c(4))
Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market01

But somehow you would have to save the last Market name and it can't be in a
m,emory variable because you would lose it when you finished running the
program and started it again.

---
Remove x's to send.


Reply With Quote
  #4  
Old   
LawyerKill
 
Posts: n/a

Default Re: Incrementing table name - 01-03-2004 , 03:38 PM



Josh Assing

Quote:
Something like:

LOCAL lcMarket
LOCAL ARRAY laMarkets[1]

ADIR(laMarkets,"Market??.dbf")

lnLast = VAL(RIGHT(JUSTSTEM(laMarkets[ALEN(laMarkets,1),1]),2))+1

lcMarket = "Market"+TRANSFORM(lnLast,"@L 99")

CREATE TABLE "&lcMarket" (;
dstock c(4))

IF USED("MarketXX")
USE IN MarketXX
endif

USE "&lcMarket" ALIAS MarketXX
LK

WOW, Thanks a lot Josh, I'll give it a try.




Reply With Quote
  #5  
Old   
Anthony Shipley
 
Posts: n/a

Default Re: Incrementing table name - 01-05-2004 , 02:58 AM



lawyerkill (AT) aol (DOT) com (LawyerKill) [WA] wrote:


Quote:
Create Table Market;
(dstock c(4))

Now I need to select something from another table and insert it into table,
'Market'

Select Bstock form Daily;
Where Ttime= THISFORM.dDate;
Into DBF Market

I think you'll find
copy structure to market01
append from market
will do what you want
regards - anthony shipley

look, ma - no .sig


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.