How can I do a SELECT Statement using Two Databases?

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
BytePlayer
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 21.09.2012, 10:13

How can I do a SELECT Statement using Two Databases?

Post 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.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

BytePlayer,

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

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Post 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
BytePlayer
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 21.09.2012, 10:13

Post 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?
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Post 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
BytePlayer
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 21.09.2012, 10:13

Post by BytePlayer »

That would be great! I'd really appreciate it.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Post 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
You do not have the required permissions to view the files attached to this post.
Locked