$Bill Luekbert wrote:
>
> Either change EXPORT_OK to EXPORT or change the use to :
>
> use Common::CSAdmin qw(GetDBHandle);
>
> Delete the return 1;
>
Thanks. I now have the module as:
##########################
package Common::CSAdmin;
use strict;
use warnings;
use DBI;
use DBD::ODBC;
require Exporter;
my @ISA = qw(Exporter);
my @EXPORT = qw(GetDBHandle);
sub GetDBHandle($) {
my $dsn = shift(@_);
my ($dbusr,$dbpwd,$server,$dbh);
$dbusr = 'usr';
$dbpwd = 'pwd';
$server = 'server';
$dbh = DBI-> connect("DBI:ODBC:$dsn", $dbusr, $dbpwd, {RaiseError => 1,
PrintError => 1}) || die "Could not connect to datasource $dsn";
return $dbh;
}
1;
and the code:
########################
use strict;
use warnings;
use DBI;
use DBD::ODBC;
use Common::CSAdmin;
my $dbh = GetDBHandle('DSN');
my $sql = <<EOF;
SELECT Test FROM tblTest
EOF
my $sth = $dbh->prepare($sql);
$sth->execute() or die "$!";
while (my ($test) = $sth->fetchrow) {
print $test . "\n";
}
$sth->finish;
##########################
but still getting
Undefined subroutine &main::GetDBHandle called at testcsadmin.pl line 7.
>
> Try to trim your posts a little better.
>
Sorry - still getting used to the etiquette on this site. Thanks for your
patience :)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs