Re: DBI: EXECing stored proc causes temporary DB context switch?
Michael Peppler <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.dbi.sybase |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 2005-09-20 at 15:15 -0400, Wechsler, Steven wrote:
> I've been experiencing this issue in a couple of scripts:
>
> If I do some DBI statements, then execute the following:
<snip>
> before sp_who: somedb
> [sp who output]
> after sp_who: master
> after sp_who 2: somedb
>
> Is there any explanation for this behavior?
The most likely explanation is that DBD::Sybase thinks that the
statement handle is still active after you retrieved the last row from
the sp_who output, and therefore opens a new connection to run the
select db_name(). Remember that sp_who and most other stored procs
return more than one result set, and so you need to loop over the result
sets, or call $sth->finish to clear the statement handle, or undefine
the $sth variable before the prepare().
You can verify this by setting the $dbh->{syb_no_child_con} = 1.
The second prepare("select db_name()") works correctly because by that
time the $sth that was still considered active has been destroyed.
Michael
--
Michael Peppler - [email protected] - http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html
--
Michael Peppler - [email protected] - http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html