On Wed, 5 Dec 2001, Craig Sharp wrote:
>I like the second option but I am a bit unsure on opening the second
>connection part. Can you expound on that area?
use DBI;
$db1 = DBI->connect("dbi:Informix:localdb",'','',{RaiseError=>1});
$db2 = DBI->connect("dbi:Informix:perfinfo@roushprod",'','',{RaiseError=>1});
$st1 = $db1->prepare("select * from localtable");
$st2 = $db2->prepare("select * from archive_info");
Now you can do fetches on either or both statement handles as you see fit.
Basically, DBD::Informix handles the connection switching for you -- one
of the benefits of the design of DBI. It opens the connections "WITH
CONCURRENT TRANSACTIONS" so that you can switch back and forth regardless
of the state of transactions.
>>>> Jonathan Leffler <[EMAIL PROTECTED]> 12/05/01 01:18AM >>>
>Craig Sharp wrote:
>>I am trying to use DBD::Informix to query a remote database. I am
>>connected to a local database and then issuing a remote sql query:
>>
>>select * from perf_info@roushprod:archive_info
>>
>>roushprod is in the sqlhosts file. The statement works correctly
>>outside of the DBD/DBI functions.
>>
>>When I try to run the statement from perl, I get the following error:
>>
>>DBD::Informix::db prepare failed: SQL: -569: Cannot reference an
>>external database with logging. at test.old line 18.
>>
>>How can I correct this problem?
>
>The problem is that your current database is unlogged but the remote
>database is logged, and you can't do remote access like that when the
>logging modes of the databases are different. The same would apply in
>DB-Access.
>
>You have several choices:
>
>* Fix the logging mode of one or the other database. This is a bit
> radical and apt to upset applications that work.
>
>* Use a second connection ($db2 =
> DBI->connect("dbi:Informix:perfinfo@roushprod", ...)). Just beware of
> shared memory connections; you can only have one of those open at any
> given time in any given process.
>
>* Close the first connection and reopen it pointing to the new database.
>
>Either of the latter two can work depending on what else you need to do;
>the middle option (second connection) is usually the best.
--
Jonathan Leffler #include <disclaimer.h>
STSM, IBM Data Management Solutions. Phone: +1 650-926-6921
Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
Guardian of DBD::Informix v1.00.PC1 -- http://dbi.perl.org
"I don't suffer from insanity; I enjoy every minute of it!"