Recent

Author Topic: tables in the different db  (Read 6011 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2258
    • Lazarus and Free Pascal italian community
tables in the different db
« on: November 03, 2011, 04:28:37 pm »
It often happens that I have two tables that I want to join that process through are on different databases (eg MySQL and the other is on about Firebird) how can I solve this problem?! Someone can explain?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: tables in the different db
« Reply #1 on: November 03, 2011, 05:23:30 pm »
You'd have to do that programmatically in your code.

Might be easier to just import data from one db into (a temporary table in) the other database.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tatamata

  • Hero Member
  • *****
  • Posts: 804
    • ZMSQL - SQL enhanced in-memory database
Re: tables in the different db
« Reply #2 on: November 03, 2011, 06:10:55 pm »
Use Microsoft Access, simple as that!
Really, it might be the biggest advantage of MS Access in comparisson to other DB tools, that it can process heterogenous queries...
Usually, I hate Microsoft, but for me MS Access is the single most brilliant application of all times!

xinyiman

  • Hero Member
  • *****
  • Posts: 2258
    • Lazarus and Free Pascal italian community
Re: tables in the different db
« Reply #3 on: November 03, 2011, 08:34:58 pm »
Access, and I hate all that is Microsoft, I already have to deal with the world of work. For my projects, absolutely not.

Anyway, thanks for the suggestion.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

goodname

  • Sr. Member
  • ****
  • Posts: 297
Re: tables in the different db
« Reply #4 on: November 04, 2011, 03:09:08 am »
Have not tried it as it is new. PostgreSQL 9.1 has a foreign table feature that reads tables in foreign databases. It specifically refers to MySQL. Don't know about Firebird though.
http://www.postgresql.org/docs/9.1/static/sql-createforeigntable.html

http://pgsnake.blogspot.com/2011/08/postgresql-91-meet-mysql.html

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: tables in the different db
« Reply #5 on: November 04, 2011, 09:49:27 am »
Firebird can also run queries in other Firebird databases, though only Firebird databases...

I concur with tatamata that MS Access is a very handy tool for this as you can link tables without copying the data. There might be other kind of query tools around that do the same but I don't know of any. If anyone does know of such a tool, please let me know.

If you feel like implementing a hierarchical dataset (a la .Net) i.e. dataset in dataset (which models a master/detail or foreign key relationship) in FPC so you can have 1 MySQL dataset that is relationally linked (Foreign key) to a Firebird dataset, I'd be happy too, but I think it's a bit more work than starting Access or importing your data  :D
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: tables in the different db
« Reply #6 on: November 08, 2011, 12:11:54 am »
Access has another drawback, it costs money (if legal) and it's not part of the MSO editions people usually buy. The other solutions are much cheaper ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

goodname

  • Sr. Member
  • ****
  • Posts: 297
Re: tables in the different db
« Reply #7 on: November 08, 2011, 02:46:08 pm »
Just found out about DBI-LINK. It is written in PERL and has been around for a few years. I'm assuming that it can read from Firebird, MySQL, and other engines that PERL can connect to.

http://pgfoundry.org/projects/dbi-link/
« Last Edit: November 08, 2011, 02:53:11 pm by goodname »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: tables in the different db
« Reply #8 on: November 08, 2011, 04:08:36 pm »
Just found out about DBI-LINK. It is written in PERL and has been around for a few years. I'm assuming that it can read from Firebird, MySQL, and other engines that PERL can connect to.

http://pgfoundry.org/projects/dbi-link/
... seems it's bound to PostgreSQL so you can get foreign data into/out of PostgreSQL, but won't help much if you've got e.g. MySQL and Firebird.

One other suggestion: you can use tools like SQLWorkbench/J to set up a copy/synchronisation job that will keep your tables in sync, so if you can live with duplicate data in 2 databases, you could use that, too.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018