Has anyone experienced a problem with Sybase::DBD not releasing the
statement handle properly when executing multiple repeated 'do' statements
in a loop?
Using DBD::Sybase, the following code normally works fine. However, during
a time that a user was experiencing a slow connection (it's not clear
whether the slowness was due to general internet traffic, or heavy load on
our server - the user is in Australia - our server in Utah), it produced
the following error:
DBD::Sybase::db do failed: Open Client Message: LAYER = (1) ORIGIN = (1)
SEVERITY =(1) NUMBER = (134) Message String ct_dynamic (PREPARE): user api
layer: external error: The specified id already exists on this connection.
The Sybase Client Lib documentation gives the following as a possible cause
for the error:
"Every Dynamic SQL call made by Client-Library has a statement identifier.
The identifier name is specified by the application during a call to
ct_dynamic with CS_PREPARE as the action type. The id, or identifier
parameter, for this call must be unique so that the statement can be
identified by the server and application.
If you call ct_dynamic with CS_PREPARE as the action type and id set to an
existing identifier name, you get this error."
--Perl code---
$::dbh->{'AutoCommit'} = 0;
eval {
$::dbh->do('delete from requests_targets where request_id=?',
undef, $request);
my $sth = $::dbh->prepare('select category_id, sub from
sessions_targets where session_id
=? and group_name=?');
$sth->execute($session,$group);
foreach (@{$sth->fetchall_arrayref}) {
$::dbh->do('insert requests_targets
(request_id,category_id,sub) values (?,?,?)', undef, $request, $_->[0],
$_->[1]);
}
$::dbh->do('delete from requests_coverage where request_id=?',
undef, $request);
$sth = $::dbh->prepare('select coverage_id, issn, coverage from
sessions_coverage where session_id=? and group_name=?');
$sth->execute($session,$group);
foreach (@{$sth->fetchall_arrayref}) {
$::dbh->do('insert requests_coverage
(request_id,coverage_id,issn,coverage) values (?,?,?,?)', undef, $request,
$_->[0], $_->[1], $_->[2]);
}
};