Thanks, Daniel!
I'll check to see how I can employ your solution (it is very *new* to me).
Regards,
Fernando
>Fernando,
>
>I don't know about Oracle, but in SQL Server you could do this with one statement on the server without going through the client. This should be
much faster. Something like this:
>
>
>*-- if the databases are on the same server
>INSERT INTO TargetDb.dbo.TargetTable SELECT * FROM SourceDb.dbo.SourceTable WHERE WhereClause
>
>*-- if the dbs are on different servers, you'd have to create a linked server and then use syntax like this:
>INSERT INTO TargetServer.TargetDb.dbo.TargetTable SELECT * FROM SourceServer.SourceDb.dbo.SourceTable WHERE WhereClause
>
>
>Since the table structures are identical, you wouldn't even have to mess with fieldnames.
>
>HTH
>
>>Hi,
>>
>>I need to create a VFP program that will copy selected records from one table to another (via SPT). For that purpose I must open two different ODBC connections, because the origin tables and destination tables reside in different Oracle databases.
>>
>>The origin and destination tables have the same structure. This program will be in charge of extracting selected records from a production database to a test database.
>>
>>If I new, in advance, the tables involved think it should be easy, but the issue is that the copy program will read parameters from a VFP table contaning wich tables to copy (table name), and what is the criteria to extract records from the origin table (the "where" clause).
>>
>>I thought doing something like the following (for each table to be copied):
>>
>>SqlExec (nOrigTableHandle, "Select * from " + cTableName + "... where " + cWhereClause, "TempCursor")
>>
>>Select TempCursor
>>Go Top
>>
>>Scan
>>
>>* Here I must move each field of each row of TempCursor to temporary variables
>>
>> . . . . (?)
>>
>>* Here I must build a string with the Insert SQL
>>
>> cInsertSqlString = "Insert Into " + cTableName + "...(?)..."
>>
>> SqlExec (nDestTableHandle, cInsertSqlString, "")
>>
>>EndScan
>>
>>What is the best way to do this?
>>
>>Any ideas will be highly apreciated.
>>
>>Regards,
>>
>>Fernando