#!/usr/local/bin/perl use strict; use DBI; use lib "./"; use db_dave; my $q = "select count(*) from tablename"; my $err = "error selecting count from tablename"; my $dbhandle = new db_dave; my $result = $dbhandle->runsql_returnString_NEW($q, $err); print $result . "\n"; ############################################## # in db_dave.pm package db_dave; @ISA = qw(DBI); ################### sub new { my ($self) = @_; $self = DBI->connect('dbi:Oracle:foo', 'foo', 'foo') || die "Cant' connect: $DBI:errstr"; print STDERR "connected \n"; bless $self, 'db_dave'; return $self; } ################### sub runsql_returnString_NEW { my ($self, $q, $err) = @_; $sth = $self->SUPER::prepare($q); $sth->SUPER::execute || &error($q, $err); my $returnstring; while (@array = $sth->SUPER::fetchrow) { $returnstring = $array[0]; } $sth->SUPER::finish; return $returnstring; } 1;