Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Move data
Message
 
 
To
10/02/2002 22:26:28
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00618148
Message ID:
00618152
Views:
9
>Hi all,
>
>I need to move data from 1 table to another table. As there fields' name is different and so I cann't just use 'APPRND FROM TABLEA' to do this. I try to use INSERT BUT VFP6.0 do not support subquery like 'INSERT INTO TABLEB(CO_NAMEB, CO_ADDB) (SELE CO_NAMEA, CO_ADDA FROM TABLEA)' there is syntax error when i run the query. As the field name and table stru is different, it seems difficult for me. I know I can use program and process it record by record but I don't wish to do it as it need some time as I have a large number of records in table. I wish I can just use one statmenet to move data.
>TABLEA:
>CO_NAMEA, CO_ADDA, CO_MANAGER, CO_REF
>
>TABLEB:
>CO_NAMEB, CO_ADDB, CO_REMARK
>

Hi Linda,

Unfortunatelly, foxpro doesn't support INSERT ... SELECT type of queries. You can acomplish your goal in a couple of ways
* Use select to rename fields
Select co_namea AS co_nameb, co_adda AS co_addb ;
  From tablea Into Cursor crsTemp
Select tableb
Append From (DBF("crsTemp"))

* Prosess record by record
Select tablea
Scan
  Insert Into tableb (co_nameb, co_addb) ;
              Values (tablea.co_namea, tablea.co_adda)
Endscan
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform