Board index » delphi » Copy data from another database

Copy data from another database


2006-01-20 05:32:39 PM
delphi19
I have 2 database
A = 192.168.0.1:C:\DATA\TEST.GDB
B = 192.168.0.2:C:\DATA\TEST.GDB
I wan to copy some data from A to B.
INSERT INTO TABLE_FROM_DATABASE_B
SELECT * FROM TABLE_FROM_DATABASE_A
How to write this SQL statement? Please help.
Thank
 
 

Re:Copy data from another database

foxcraft escreveu:
Quote
I have 2 database
A = 192.168.0.1:C:\DATA\TEST.GDB
B = 192.168.0.2:C:\DATA\TEST.GDB

I wan to copy some data from A to B.

INSERT INTO TABLE_FROM_DATABASE_B
SELECT * FROM TABLE_FROM_DATABASE_A

How to write this SQL statement? Please help.

Thank


Hi,
You cannot.
Just use two separate SQL statements one for Select values and the other
to Insert.
HTH
Antonio
 

Re:Copy data from another database

How? can u give me a simple example?
Thank
"Antonio Felix" <XXXX@XXXXX.COM>writes
Quote
foxcraft escreveu:
>I have 2 database
>A = 192.168.0.1:C:\DATA\TEST.GDB
>B = 192.168.0.2:C:\DATA\TEST.GDB
>
>I wan to copy some data from A to B.
>
>INSERT INTO TABLE_FROM_DATABASE_B
>SELECT * FROM TABLE_FROM_DATABASE_A
>
>How to write this SQL statement? Please help.
>
>Thank
>
>

Hi,

You cannot.
Just use two separate SQL statements one for Select values and the other
to Insert.

HTH
Antonio
 

Re:Copy data from another database

foxcraft escreveu:
Quote
How? can u give me a simple example?
If you have two TIBSQL components (InSql and OutSql) connected to each
Database;
...
YourTransaction->StartTransaction();
InSQL->SQL->Clear();
InSQL->SQL->Add( "Select * from SOURCETABLE");
InSQL->Prepare();
OutSQL->SQL->Clear();
OutSQL->SQL->Add( "Insert Into DESTTABLE (FIELD1, FIELDN) values
(:FIELD1, :FIELDN)");
OutSQL->Prepare();
InSQL->ExecQuery();
while ( !InSQL->Eof ) {
OutSql->Params->ByName("FIELD1")->AsString =
InSQL->FieldByName("FIELD1)->AsString;
OutSql->Params->ByName("FIELDN")->AsString =
InSQL->FieldByName("FIELDN)->AsString;
OutSQL->ExecQuery();
InSQL->Next();
}
YourTransaction->Commit();
HTH
Antonio
}
You need a separate connection to each Database.
TIBSQL *In = new TIBSQL( this )
 

Re:Copy data from another database

InterBase does not support SQL statements that access two databases.
Use the free IB DataPump at
www.clevercomponents.com/products/datapump/ibdatapump.asp
or write a program to move the data.
--
Bill Todd (TeamB)