[CDBI] Using Class::DBI across multiple databases on one server (Sybase)

IvorW i2ia-14dq at xemaps.com
Tue Aug 23 11:54:59 BST 2005


I have an issue where I am needing a transaction to update across multiple databases. I can do this in SQL using the database..table notation. 

I have an existing CDBI suite of classes that use a separate database connection for each database. But this doesn't work with transactions on both connections owing to the way Sybase handles chained transactions. If they were sharing one channel, this would give me what I want.

I have no choice over the fact that the tables are in two different databases. Here is an illustration of what I want to do.

package DB::Connect;
use base qw(Class::DBI);

__PACKAGE__->set_db("dbi:Sybase:server=SYB_PROD;database=SALESDB",$user,$passwd);

package DB::Order;
use base qw(DB::Connect);

__PACKAGE__->set_up_table("ORDER");
__PACKAGE__->has_a( account => 'DB::Account');

package DB::Account;
use base qw(DB::Connect);

__PACKAGE__->set_up_table("REFERENCEDB..ACCOUNT");
...

It seems that table and set_up_table don't support "database.schema.table" syntax unless I am missing something.

Any help would be appreciated.

Ivor.





More information about the ClassDBI mailing list