Subject RE: [firebird-support] Multidatabase query
Author Gustavo
I have an ERP application with wich you can manage multiple enterprises. So I have one database per each enterprise plus one database with the common data (countries, states, etc.).

Gustavo

----- Mensaje original -----
De: Daniel Rail
Para: firebird-support@yahoogroups.com
Enviado: Martes, 10 de Mayo de 2005 13:25
Asunto: Re: [firebird-support] Multidatabase query


Hi,

At May 10, 2005, 12:36, Gustavo wrote:

> Hello:

> Suppose I have two databases named Database1 and Database2. In
> Database1 there is a table named Table1 with fields Field11 and
> Field12 and in Database2 there is a table named Table2 with fields
> Field21 and Field22. The question is:

> Is it possible to make a multidatabase query like the following?

> SELECT Table1.*, Table2.Field22
> FROM Database1.Table1, Database2.Table2
> WHERE (Table1.Field11 = Table2.Field21)

> I'm using Delphi 5 and IBX. I use the TQuery component but in its
> property Database I can assign only one database.

And, at the present time, a query can only reference one table at a
time. It has been talked about for a future version(probably post
version 3.0)

> If it´s impossible to do this with Firebird... Does anybody have
> any idea of how can I obtain my query in another way?

One way is to use TIBQuery's calculated fields, and assign the values
from the second database. And, if you need limit the result set to
only the matching records of both tables, then you can use the
TIBQuery.OnFilterRecord event.

Also, what is the reason why you are using more than one database in
your design?


--
Best regards,
Daniel Rail
Senior Software Developer
ACCRA Consultants Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




------------------------------------------------------------------------------
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

b.. To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




[Non-text portions of this message have been removed]