>On Mon, Mar 31, 2003 at 02:01:30PM -0800, Michael Peppler wrote:
>> On Mon, 2003-03-31 at 11:36, Karyn Ulriksen wrote:
>> > This worked pretty well before. But, now, it appears that if the
result of
>> > the query is a null set, it pukes with a:
>> >
>> > Can't get DBI::st=HASH(0x811cfa8)->{NAME}: unrecognised attribute at
<my
>> > package>
>>
>> Hmmm - I don't think that this is a problem with DBD::Sybase. However I
>> believe that there was (or maybe still is) a bug with FreeTDS and empty
>> result sets where the columns don't get set up correctly.
>
>Odd that it should say that NAME is unrecognised, rather than return
>a ref to an empty array - which would seem like a better failure mode.
>
>Tim.
Tim,
I couldn't agree with you more. Not only odd, but annoying. Here is the
pertinent info on my package:
#########################
package SomePackage;
use Fcntl;
use MLDBM qw(DB_File);
use strict;
use DBI;
use lib '/d/lib';
use InSite::DB::Conf;
sub new {
my $proto = shift @_;
my $class = ref( $proto ) || $proto;
my $self = {};
my($dbuser) = 'sa';
my $conf = InSite::DB::Conf->new();
my($dbpass) = $conf->{"$dbuser"};
$self->{DBI_URL} = "dbi:Sybase:server=idx68;database=insite";
$self->{DBI_USERNAME} = "$dbuser";
$self->{DBI_PASSWORD} = "$dbpass";
bless( $self, $class );
return $self;
}
sub getDBH {
my $self = shift;
if(! ref($self)) {return undef;}
if(! defined($self->{DBH})) {
$self->{DBH} = DBI->connect( $self->{DBI_URL},
$self->{DBI_USERNAME},
$self->{DBI_PASSWORD} );
$self->{DBH}->{RaiseError} = 1;
$self->{DBH}->do("set textsize 65536");
}
else {$self->{DBH}->ping();}
return $self->{DBH};
}
# [ ... other sub routines not included ... ]
sub retrieve_service_by_name {
my $self = shift;
my $svcname = shift;
my (%info, $ref, $sth);
$svcname =~ s/\s+/ /g;
$svcname =~ s/^\s+//;
$svcname =~ s/\s+$//;
if($svcname eq "") { return; }
my($dbh) = $self->getDBH();
my($qname) = $dbh->quote("$svcname");
my $q = "select * from services where \( service_label = $qname
\)";
$sth = $dbh->prepare("$q");
$sth->execute();
while ($ref = $sth->fetchrow_hashref) {
foreach my $key (keys %{$ref}) {
$info{"$key"} = $$ref{"$key"};
}
}
return %info;
}
1;
##########################
I hope this helps to clarify "something".
Thanks!
Karyn