Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Using a single database handle or multiple handles

by tobyink (Abbot)
on Oct 11, 2012 at 13:45 UTC ( #998446=note: print w/replies, xml ) Need Help??


in reply to Using a single database handle or multiple handles

Depends on the database. For most, a single handle is preferable.

Microsoft SQL Server (and presumably Sybase too), when connected to using the TDS libraries does not allow multiple concurrent queries to execute on the same handle. You need to finish one query before making another. Thus patterns where you do:

my $results = $dbh->someQuery; while (my $row = $results->fetchrow_array) { $dbh->someOtherQuery; }

will not work unless you open a second connection. (I think some newer versions of TDS do actually emulate concurrent queries by transparently opening a second connection when required.)

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Using a single database handle or multiple handles
by mje (Curate) on Oct 12, 2012 at 09:40 UTC

    Newer MS SQL Server drivers (and some other commercial ones) have an attribute called MARS_Connection which when set to 1 enables Multiple Active Result Sets. However, it is generally slower and has a number of restrictions. I wrote a small article on it for DBD::ODBC at Multiple Active Statements (MAS) and DBD::ODBC.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998446]
help
Chatterbox?
[robby_dobby]: marto: Oh, I see you're from an even colder north :-)
[robby_dobby]: marto: Ldn, right now
[marto]: icy here today, snow on the hills
[Corion]: Oh yes, Friday!
[Corion]: Last day at $work before 3 weeks of vacation (well, not that I'd be really travelling, but no-work-time ;) )
[robby_dobby]: marto: yeah, I'd eventually visit Glasgow some day - just to visit the home town of GHC :-)
[robby_dobby]: Corion: Oh, that's awesome! Your timing is perfect enough to see all hell break loose when you get back at work :P
[marto]: well, let me know in advance, I'll buy you a pint :)
[Corion]: robby_dobby: No, I'm returning in the second workweek of January. The main hectic parts are in the first days after the start of the new year
[robby_dobby]: marto: and, I'm not sure I'd be around here long enough for YAPC::EU

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-12-15 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (431 votes). Check out past polls.

    Notices?