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: "Wechsler, Steven" <Steven dot Wechsler at mtvstaff dot com>
Subject: DBI: EXECing stored proc causes temporary DB context switch?
Date: Sep 20 2005 7:15PM

I've been experiencing this issue in a couple of scripts:

If I do some DBI statements, then execute the following:

            $sth = $dbh->prepare("select db_name()");
            $sth->execute;
            while (@row = $sth->fetchrow_array) {
                print "before sp_who: $row[0]";
            }
            $query = "exec sp_who";
            $sth = $dbh->prepare($query);
            $sth->execute;
            undef $select;
            while (@data = $sth->fetchrow_array) {
                print @data;
            }
            $sth = $dbh->prepare("select db_name()");
            $sth->execute;
            while (@row = $sth->fetchrow_array) {
                print "after sp_who: $row[0]";
            }
            $sth = $dbh->prepare("select db_name()");
            $sth->execute;
            while (@row = $sth->fetchrow_array) {
                print "after sp_who 2: $row[0]";
            }

I get this:

before sp_who: somedb
[sp who output]
after sp_who: master
after sp_who 2: somedb

Is there any explanation for this behavior?

Thanks,

Steve