PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: DBI: EXECing stored proc causes temporary DB context switch?
Date: Sep 21 2005 3:40PM

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:



> 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  -  mpeppler@peppler.org  -  http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html

-- 
Michael Peppler  -  mpeppler@peppler.org  -  http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html