oops, meant to reply to the list.

---------- Forwarded message ----------
From: Jeffrey Seger <[EMAIL PROTECTED]>
Date: Oct 15, 2005 9:34 PM
Subject: Re: DBD-AnyData, Handle cleared whilst still active...
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>

I haven't traced it all the way down because the code is workign as
designed, but putting the $sth->finish in didn't help. The result set was
also fully fetched and processed. The issue also went away when I switched
dsn's from Redbrick via ODBC to Oracle. Other than changing from
current_time to sysdate, the code was exactly the same.

If it matters, the DataBase Handles were created in child pids and lived
their entire lives in the child pid.

#just bcause this global is referenced in the function below.
my $TIMEFUNC = ($dsn =~ /ODBC/i) ? 'current_time' : (($dsn =~ /Oracle/i ) ?
'sysdate' : 'null');

sub set_status{
my $dbh = shift;
my $server = shift;
my $group = shift;
my $file = shift;
my $status = shift;


#this can return only one row as server,server_group,file_name is the PK on
this table.
my $check_sql = "select status from
logpull_hist
where server = ?
and server_group = ?
and file_name = ?";

my $insert_sql = "insert into
logpull_hist (status,status_time,server,server_group,file_name)
values(?,$TIMEFUNC,?,?,?)";

my $update_sql = "update logpull_hist
set status = ?, status_time = $TIMEFUNC
where server = ?
and server_group = ?
and file_name = ?";

$status = uc($status);

my $update = 0;
my $already_complete = 0;

my $sth = $dbh->prepare($check_sql);
$sth->execute( $server,$group,$file)|| die "unable to execute $check_sql";
while(my ($old_status) = $sth->fetchrow_array()){
$update = ($old_status =~ /F/i) ? 1 : 0;
$already_complete = ($old_status =~ /C/i) ? 1 : 0;
}

if ($already_complete){
$sth->finish();
return;
}

my $sql = (!$update && $status =~ /R/i) ? $insert_sql : $update_sql;

$sth = $dbh->prepare($sql) || die "unable to prepare $sql";

$sth->execute( $status,$server,$group,$file) || die "unable to execute
$sql";

$sth->finish();
}


On 10/15/05, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:
>
>
> > -----Original Message-----
> > From: Jeffrey Seger [mailto: [EMAIL PROTECTED]
> > Sent: Friday, October 14, 2005 07:00 PM
> > To: dbi-users@perl.org
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: DBD-AnyData, Handle cleared whilst still active...
> >
> > I'm getting the exact same warning in a script that uses DBD::ODBC
>
> My message about the bug was specific to DBD::AnyData and does *not* apply
> to DBD::ODBC or other DBDs.
>
> The most common reason for this error (in general, not specific to
> AnyData) is forgetting to use finish() on a statement handle that hasn't
> been fully fetched so I'd suggest looking there.
>
> --
> Jeff
>
>
>


--
It all comes down to a choice really.
You can get busy living, or get busy dying.
--Stephen King


--
It all comes down to a choice really.
You can get busy living, or get busy dying.
--Stephen King

Reply via email to