Re: Class::DBI::Oracle vs Class::DBI::Loader

[prev] [thread] [next] [Date index for 2005/02/22]

From: Ian VanDerPoel
Subject: Re: Class::DBI::Oracle vs Class::DBI::Loader
Date: 22:52 on 22 Feb 2005
Dave,

That should not be a problem.

Code follows.


---------------------------------------------------------

package Class::DBI::Loader::Oracle;
use strict;
use DBI;
use Carp ();
require Class::DBI::Oracle;
use base qw(Class::DBI::Loader::Generic);
use vars qw($VERSION);
$VERSION = '0.02';
sub debug { 0 };
sub _croak { require Carp; Carp::croak(@_); }
sub _load_classes {
    my $self = shift;
    my $user = uc $self->_datasource->[1];
    if (debug) { printf STDERR "%s: start for user %s\n",__PACKAGE__,
$user; }
    my $dbh = DBI->connect(@{$self->_datasource}) or
_croak($DBI::errstr);
    if (debug) { printf STDERR "%s: connected\n",__PACKAGE__; }
    my @tables = $dbh->tables(undef, $user, '%', 'TABLE'); #   
catalog, schema, table, type
    foreach my $table(@tables) {
        if (debug) { printf STDERR "%s: table is %s\n", __PACKAGE__,
$table; }
        $table =~ s/"//g;
        $table =~ s/\w+\.//;
        next if $table eq 'PLAN_TABLE';
        $table = lc $table;
        if (debug) { printf STDERR "%s: table now %s\n", __PACKAGE__,
$table; }
        my $class = $self->_table2class($table);
        no strict 'refs';
        @{"$class\::ISA"} = qw(ITSRR::AllTables); # if we want to get
our app-level triggers! Else Class::DBI::Oracle
        $class->set_db(Main => @{$self->_datasource});
        $class->set_up_table($table);
        $self->{CLASSES}->{$table} = $class;
    }
    $dbh->disconnect;
}

1;

-------------------------------------------------------



Regards

IAN

>>> David Naughton <naughton@xxx.xxx> 23/02/05 9:46:14 AM >>>
Ian,

Thanks for your reply. Comments and source would be great. Does that
mean your colleague probably isn't interested in releasing and
maintaining
CDBI::Loader::Oracle, and would let me do it, based on his code?

Dave

On Wed, Feb 23, 2005 at 08:28:27AM +1100, Ian VanDerPoel wrote:
> Dave,
> 
> My coleague has built a CDBI::Loader::Oracle. It was posted on the
Wiki
> about 5 months ago, but seems to have been lost. It is merely a crib
on
> one of the other loaders. He should be in the office shortly. I will
get
> him to respond with comments and source.
> 
> Regards
> 
> IAN
> 
> >>> David Naughton <naughton@xxx.xxx> 23/02/05 7:58:39 AM >>>
> Jay,
> 
> I was just talking to Sebastian Riedel, maintainer of CDBI::Loader,
> about doing CDBI::Loader::Oracle. Is it still true that you haven't
> gotten around to it?
> 
> Everyone,
> 
> If anyone is already working on CDBI::Loader::Oracle, please let me
> know. Wheel re-invention and all that.
> 
> Thanks,
> David Naughton
> 
> On Thu, Feb 17, 2005 at 08:24:22AM -0600, Jay Strauss wrote:
> > Johan Lindstrom wrote:
> > >Does anyone know how Class::DBI::Oracle and Class::DBI::Loader
> relate to 
> > >each other? Are they connected at all? Do the complement each
> other?
> > >
> > >My base CDBI class inherits from
> > >use base qw/ Class::DBI::Oracle /;
> > >
> > >In a CDBI class for a table I inherit from the base class and do:
> > >__PACKAGE__->set_up_table('op_operator');
> > >
> > >This works fine, but I don't get auto-detection of has_many 
> > >relationships from foreign keys in the schema.
> > >
> > >Can I get that functionality from CDBI::Oracle? Can I switch to 
> > >CDBI::Loader and still have my module files for each table class?
(I
> 
> > >have other methods and properties in some of the classes).
> > >
> > >
> > >/J
> > >-------- ------ ---- --- -- --  --  -     -     -        -        

> -
> > >Johan Lindstr*m    Sourcerer @ Boss Casinos   johanl AT
> DarSerMan.com
> > >
> > >Latest bookmark: "TCP Connection Passing"
> > >http://tcpcp.sourceforge.net/ 
> > >dmoz: /Computers/Programming/Languages/JavaScript/ 12
> > >
> > >
> > >
> > >
> > Loader doesn't work with Oracle, last I looked, I think it only
works
> 
> > with postgresql and mysql.  I've thought about doing all that 
> > autodetection stuff in a class::dbi::loader::oracle but have never

> > gotten around to it.
> > 
> > Jay
> 
> 
>                                        
> 


                                       

Class::DBI::Oracle vs Class::DBI::Loader
Johan Lindstrom 21:58 on 16 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Jay Strauss 14:24 on 17 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 20:58 on 22 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Ian VanDerPoel 21:28 on 22 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 22:46 on 22 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Jay Strauss 15:19 on 23 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Johan Lindstrom 15:29 on 23 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Jay Strauss 15:39 on 23 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 16:07 on 23 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Dan Sully 17:40 on 23 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Ian VanDerPoel 22:52 on 22 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Frank Carnovale 00:42 on 24 Feb 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 03:52 on 24 Feb 2005

[ANNOUNCE] Class::DBI::Loader::Oracle 0.01
David Naughton 16:26 on 09 Mar 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 16:57 on 09 Mar 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
Frank Carnovale 02:30 on 11 Mar 2005

Re: Class::DBI::Oracle vs Class::DBI::Loader
David Naughton 21:22 on 11 Mar 2005

Generated at 08:54 on 14 Mar 2005 by mariachi v0.52