Subject Re: [firebird-support] How do you concurrently access a Firebird embedded database & server database?
Author Helen Borrie
At 11:41 PM 2/03/2006, you wrote:
>Is it possible to have a connection open to a Firebird embedded
>database and have another connection open to a Firebird database on a
>server at the same time from within one program?

First, "embedded" doesn't mean "embedded database", it means "client
with an embedded server". So fbembed.dll is a client + a server.

>
>Since two different versions of fbclient.dll are needed, how is it done?

Just start a cross-database transaction and connect through the
external server to its database as a normal remote client; and
connect to your local database through the embedded server.

>
>I want to copy some rows from some of the tables in a Firebird
>database on a server to the Firebird embedded database. I do not want
>to export the data to a flat file first but instead want to perform
>the copy in one step within the same program.

You can't ever copy directly from one database to another. You need
to read the data in one database and write it by some means in the other.

IB Objects, for example, has a very efficient datapump component that
does this. In a single transaction, you connect to the source
database and write a SELECT query to acquire the data; you connect
to the target database and write a parameterised INSERT or UPDATE
statement (or an EXECUTE PROCEDURE statement, if you decide to go
that way). In between, with both statements in a prepared state, you
can set up the mapping of the incoming fields to the parameters and
anything else you might want to do to massage the data.

Then you just call the Execute method of the datapump and it does all
the stuff: it streams in the data for a row, does the massaging and
then applies the mapped values to the parameters of the target
statement, writes to the target, then loops back and fetches the next
row from the source's output.

(This is a great roll-your-own for Delphi programmers but it's
actually available as a tailor-made in the free IB_SQL application,
downloadable from the IBO website.)

./heLen