INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Altering a table structure to match a new DBF template.

Altering a table structure to match a new DBF template.

(OP)
An application has been issued to several customers, and the underlying structure of one table needs to be altered (by program), to match the new layout. The changes are mainly the addition of new fields and changing the length of some fields.

I can do this up to a point by opening the live data and the new template, examining the fields in both tables with the AFIELDS() function; then using the ALTER TABLE command to add the new fields into the live data.

This works, and the application runs, using the new fields. However the fields in the live data may not be in the same order as those in the template.

So : the (existing) live data has fields :
Account C(8), Addr1 C(30), Postcode C(8)

and the new template has fields :
Account C(8), Addr1 C(30), Addr2 C(30), Postcode C(8)

After updating the live data, it has fields :
Account C(8), Addr1 C(30), Postcode C(8), Addr2 C(30)

As mentioned, the live data has all the fields to make the updated application work, but it would be nice to have the layout identical to the new template, with the fields in the same order.

Thanks.

RE: Altering a table structure to match a new DBF template.

You should rethink your idea of having the fields in a specific order. At least that's my opinion. The big question is WHY you want this, I don't think you can come up with a good enough reason to justify the extra work.

RE: Altering a table structure to match a new DBF template.

Andrew,

The only way to do this programmatically would be to create entirely new tables containing the fields in the desired order; then append the data from the old tables; then delete the old tables; then rename the new tables to match the original names.

Whether this will be worth the trouble (including possibly a certain amount of inconvenience for the customer) is for you to decide.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close