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

[prev] [thread] [next] [Date index for 2005/08/25]

From: Matt S Trout
Subject: Re: [CDBI] Using Class::DBI across multiple databases on one server (Sybase)
Date: 05:47 on 25 Aug 2005
On Tue, Aug 23, 2005 at 06:54:59AM -0400, IvorW wrote:
> 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.

set_up_table isn't a part of Class::DBI; it's something provided by a number
of the db-specific subclasses but is no part of Class::DBI itself and it's
probably what's breaking here.

I suspect if you just used ->table and called ->columns yourself, it
would work. Try it, and use DBI->trace(1) (or a higher value) to see what
SQL Class::DBI is generating if it doesn't work. If that doesn't help,
reply with the explicit classes and the trace and I'm sure somebody on
here can have a go.

        -- 
             Matt S Trout        Specialists in OSS web application development and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

Re: [CDBI] Using Class::DBI across multiple databases on one server (Sybase)
Matt S Trout 05:47 on 25 Aug 2005

Generated at 10:42 on 28 Aug 2005 by mariachi v0.52