Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to rename a table of a database?
Message
From
18/12/2006 05:37:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01178413
Message ID:
01178497
Views:
17
>I am having a tough time create a little routine to rename a table in a database. I want to add a TEMP table to a database of the same structure as one of the existing. Then drop the original table and rename the TEMP table into the original.
>
>Here is what I do:
>
>cTblName = "MyTable"
>use (cTblName)
>afields(aDbfStruct)
>set database to MyDatabase
>create table TEMP name TEMP from array aDbfStruct
>close tables
>drop table (cTblName)
>rename table ("TEMP") to (cTblName)
>*-- I was hoping that rename table will rename actual file name
>*-- but it does not. So I have to do this:
>rename ("TEMP.DBF") to (cTblName + ".DBF")
>rename ("TEMP.FPT") to (cTblName + ".FPT")
>
>
>But the table MyTable.DBF is not part of the database after all of that.
>
>What am I missing?
>
>Thank you.

Dmitry,
I would use gendbc generated code edited for this kind of job. However using this code you could do it with a slight change:

>
cTblName = "MyTable"
use (m.cTblName)
afields(aDbfStruct)
set database to MyDatabase
close tables
drop table (m.cTblName)
create table (m.cTblName) from array aDbfStruct
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform