[ic] Database Handle and Global Subs

Mark Johnson interchange-users@lists.akopia.com
Fri Jun 8 09:29:00 2001


Assuming you wish to run against the same database defined for "some"
interchange table, say 'dbi_table':

my $dbh = Vend::Data::database_exists_ref('dbi_table');
$dbh = $dbh->ref();
$dbh = $dbh->[$Vend::Table::DBI::DBI];

This will give you the database handle for the DBI database that
contains the table 'dbi_table'. Note that the actual table you query can
be any table in the database and not just 'dbi_table', be it an
IC-recognized table or not.

Sheamus Nulty wrote:
> 
> I trying to run a database query in a global tag but am running into a
> problem with getting access to the database.
> I'm using the following code
> 
> sub test{
> 
> use DBI;
> 
> my $dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpasswd);
> .....
> 
> }
> 
> and I get an error saying
> 
> Can't locate object method "connect" via package "DBI" at (eval 91) line 14.
> 
> Can anybody shed some light on why this won't work.
> 
> Thanks
> 
> Sheamus
> 
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users

-- 
Mark Johnson
Senior Systems Architect - Professional Services
Red Hat, Inc.
E-Business Solutions
markj@redhat.com
703-456-2912