Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't add foreign key programmatically?
Message
From
05/02/2003 15:35:35
 
 
To
05/02/2003 13:56:18
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00749448
Message ID:
00749540
Views:
35
Steve, Garrett

Thanks. The reason I am trying to use alter table is that I am building a program that will allow us to make all of our table changes for this application programmatically, and, provide an audit trail on the date and time the change was made. So I am putting alter table statements into a memo field of a table. We have a situation where there are multiple copies of the same database (actually, in this case, sets of free tables in a folder), with one set of tables/database per client that the application runs for. So we need a routine that allows us to first update structures to a 'master database/tables set), and then we need to propagate all those changes to the remaining clients tables.

I was hoping to have one sql statement per change in the memo field of a table I call 'PendingStructureChanges'. For each change I execute $lcSqlStatement. Then, when done, move to a table called CompletedStructureChanges, and record the completion date.

However, I may need to treat each memo field as a prg, i.e. copy the contents of the memo field (formatted as a prg) to a temp text file then call the prg in the text file. In this case I would put the following in the memo file:

use inventory
index on kit tag kit

Maybe this approach is more flexible anyway, because it allows me to execute a series of data manipulation commands, not just one. But on the other hand, I was also hoping to enhance it such that I could construct alter table (or any other type of Data structure manipulation statement) via an end user interface, so that the user wouldn't have to know sql

Any ideas on how to approach this application?




>David,
>
>Yes, the REFERENCES clause is required.
>
>< UPDATE >
>Hmmm...I'm not sure exactly what it does in the DBC...
>< /UPDATE >
>
>What is wrong with using INDEX ON command?
>
>>I need to clarify this post:
>>
>>1) I am working with a FREE TABLE. I want to add an index tag using alter table.
>>
>>2) I am not sure this accomplishes what I want - I want to just create a tag. I don't need to set up a relationship betwen tables.
>>
>>3)I see an example in the help that says:
>>
>>ALTER TABLE orders;
>> ADD FOREIGN KEY cust_id TAG cust_id REFERENCES customer
>>
>>I guess the references clause is required, and sets up a relationship between the two tables? When I add the references clause - I get the error that non-dbc tables are not supported.
>>
>>>Instead of opening my table inventory, and then executing:
>>>
>>>index on kit tag kit
>< snip >
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform