Einzelnen Beitrag anzeigen

Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#15

AW: Tabellen aus verschiedenen Datenbänke in einem DBGrid

  Alt 22. Jan 2020, 21:24
Zitat:
Can I do multi-database or cross-database queries with Firebird?

Short answer: You cannot. Firebird 2.5 introduces some basic support though...

The only way is to pump the data from one to another using tools like IBDataPump, FBCopy, FBExport, or some of administration tools that have this option. See FAQ #20 for details.

You can, however, do the multi-database transactions: have a one transaction that reads and changes data in multiple database. Firebird's ACID compliant and ensures that this is possible.

Firebird 2.5 introduces a way to query the external data sources in PSQL. EXECUTE STATEMENT has been extended with a special clause: ON EXTERNAL DATA SOURCE, and you can supply a different Firebird database as a data source. This means that you can fetch data from another database into PSQL variables. You cannot do JOINs with tables in different databases, but this is a nice start. Example:

execute block returns (emp_no smallint) as
begin
FOR EXECUTE STATEMENT 'select emp_no from employee'
ON EXTERNAL DATA SOURCE 'localhost:employee' AS USER 'sysdba' PASSWORD 'masterkey'
INTO :emp_no
DO SUSPEND;
end

As you can see, using aliases becomes important and there is still a lot to be desired, but it's enough to cover some of the most basic needs.
(siehe http://www.firebirdfaq.org/faq16/)

Mach für jede DB je eine Connection und eine Query, und pack die Ergebnisse in ein normales Stringgrid.
Das ist einfacher und sicherer als die angestrebte Lösung.
Oder leg eine dritte Datenbank an, die aus den Daten der beiden anderen gespeist wird, oder leg in der einen DB zusätzliche Tabellen an, die aus der anderen DB gefüllt werden. Alles kein Hexenwerk und mit jedem DBMS zu realisieren.


Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat