Page 1 of 1

How can I do a SELECT Statement using Two Databases?

Posted: 03.10.2012, 12:13
by BytePlayer
I'm using Delphi EX2 and SQLite3 and I have two separate database files that I need to merge via an SQL statement like:

INSERT INTO DatabaseOne.TableOne (FieldNameOne, FieldNameTwo, FieldNameThree)
SELECT FieldNameOne, FieldNameTwo, FieldNameThree
FROM DatabaseTwo.TableOne

I have a feeling that a tzGroupConnection is the way to go but I can't figure out how to use them at all...!

Any help would be greatly appreciated, particularly if you could give me some sample code!

Thanks in advance.

Posted: 05.10.2012, 10:52
by EgonHugeist
BytePlayer,

i've no expierienses with that component. So if you find out how post it here..

Posted: 05.10.2012, 16:04
by marsupilami
Hello BytePlayer and EgonHugeist,

Maybe this thread helps about TZConnectionGroup and TZGroupedConnection: http://zeos.firmos.at/viewtopic.php?t=2760

Byteplayer, if I understand that thread correctly, these components will not help you. The special case in your first post seems to be the normal use case for a data pump? Maybe some RDBMSs might allow Queries betwen different databases. But imo this is not the usual case. So what RDBMS do you use? (MS SQL, Sybase ASE / ASA, Firebird, SQLite, ...)

Best regards,

Jan

Posted: 05.10.2012, 21:28
by BytePlayer
SQLite3 --- Alternatively do you know is there an existing way to dump a DB to an SQL Query and then run that on the new DB?

Posted: 08.10.2012, 16:16
by marsupilami
Hello BytePlayer,

a component for creating sql scripts for inserting - that is something on my todo list. What I can give you is a data pump component. This component is in a state, where I can say, it works for me and some of my customers. If you want to, I can publish it here and write some kind of small introduction on how to use it.
Best regards,

Jan

Posted: 08.10.2012, 22:31
by BytePlayer
That would be great! I'd really appreciate it.

Posted: 10.10.2012, 14:49
by marsupilami
Hello BytePlayer,

please have a look at the attached components. This is the data pump described earlier and an SQL-Dump generator. Both have limitations. Until now I only use them with Zeos 6.6.6 and Delphi. So if you use newer Delphi versions, especially unicode eneabled ones, or Zeos 7 your mileage might vary.

For using the components, just drop the pas files into a new package, compile and install it. Both files contain a register procedure that will register these both components to your component palette in a Tab called IKS.

The textfiles contain a brief description of the components. The folders contain demo projects. I think that especially for the data pump this is necessary because I had to make some ugly design decisions there ;o)

If you have questions, just ask me.

Best regards,

Jan