Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying from one database to another
Message
From
17/09/2003 09:56:47
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
16/09/2003 21:25:09
Jordan Pastourel
Worksafe Management Systems
Toowong, Australia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00829703
Message ID:
00829848
Views:
25
>>>Hi all,
>>>what i am trying to do is copy the data from one database to another. what i do is work out if one has the same table as the other, and if it does i then copy the information from the corresponding fields into the new database.
>>>my issue is, when you append blank in the new database and issue the replace statement, how do you specify from which database it comes from?
>>>
>>>thanks,
>>>Jordan
>>
>>Can't you just use APPEND FROM to copy the entire table in one command? As to the origin, I think you can specify the full path.
>
>i can't just APPEND FROM as there might be extra fields in either of the tables. i am copying just the fields that are similar to both.
>can i use the DATABASENAME!tablename.fieldname syntax in the replace statement?

APPEND FROM will copy the fields that have identical names in both. If you rename a field, indeed, you need to use more detailed programming. Otherwise, you should have no problem with APPEND FROM.

But even if you write a loop and use SCATTER NAME for each record (for example), I think you can still write the full path (or a relative path) of the table explicitly. I will assume that you have neatly separated the databases into separate folders.

Something like this:
close database all
use Data1\Table1 in 0 alias Origin
use Data2\Table1 in 0 alias Destination
select Destination
zap
select Origin
scan
  scatter name loRecord
  * Possible changes to the loRecord properties would go here
  select Destination
  append blank
  gather name loRecord
endscan
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform