Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Can i execute two queries connecting to same DB at a time.

by Jenda (Abbot)
on May 07, 2009 at 12:08 UTC ( #762583=note: print w/replies, xml ) Need Help??


in reply to Can i execute two queries connecting to same DB at a time.

Sure you can execute two queries at a time in a database. It would be a fairly useless database if you could not. You don't necessarily have to be able to execute two queries using one database CONNECTION, though. But what the heck? Just open another one.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re: Can i execute two queries connecting to same DB at a time.

Replies are listed 'Best First'.
Re^2: Can i execute two queries connecting to same DB at a time.
by afoken (Abbot) on May 07, 2009 at 14:51 UTC

    Yes, this is a workaround. But it comes at a cost: Transactions are per connection, not per program. You can't rollback two SQL commands that work on two connections. You can rollback each one separately, but not both at once. And yes, this is an important difference.

    If you use more than one connection, use only one distinct conection for database modifications (insert, update, delete), and the other connections only for reading (select). This way, transactions still work.

    Another workaround is to buffer the results from the first SQL statement, finish() it, and then process the next SQL statement.

    An even better solution is to get a proper RDBMS. There are several available, some even free as in beer and speech.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      How standards have changed for a "proper RDBMS". Microsoft gets that design limitation from Sybase, which back in the day did a lot to convince everyone of the importance of having databases with ACID guarantees.

      And now today merely having decent performance and ACID guarantees is not enough to be called a proper RDBMS.

      Erm. Sorry to stomp on your sand castle, but ... it's not MSSQL that doesn't allow multiple open resultsets. It's DBD::ODBC. MSSQL does support that, since version 6.0.

      "Proper RDBMS". Yeah. Sure. If you want to slander, try to make sure you're not kidding.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        DBD::ODBC does support MAS and MARS, as documented in DBD::ODBC::FAQ. But unlike a proper RDBMS, MAS and MARS require special coding and have surprising side effects. Those problems come from the underlying communication protocol (and probably the MS SQL Server code itself) and do not exist in Oracle, PostgreSQL and other RBDMSs.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762583]
help
Chatterbox?
[james28909]: im not quite how to explain it any better nick. you evolved from ignorance to intelligence. not the other way. the universe evolves from gas coulds and debris into planets stars and galaxies ect. it doesnt happen any other way. hence it has ....
[james28909]: some kind of logic behind it
[james28909]: and that is also anothe rpoint i made, i think it has to do with perception of the world around you. most people think of evolution on a human scale. why could life evolve on this planet? because this planet evolved in this solar system. and so on.
[holli]: here's something for you to watch, James. I think you will like it
[erix]: for the record: I have not downvoted anyone on that subthread that was my fault
[james28909]: there are all kinds of things that had to happen to let life come to be. but at the same time, life may not be the end goal IF there is any kind of end goal lol
[james28909]: well who is the person who gets to decide which behaviour is worthy of a downvote? a person with their own beliefs? xD
[erix]: teleology -- I've never understood why that was thunk up
[erix]: ( and when teleology was brought up, during my biology-study., I couldn't get an answer either )
[1nickt]: FTR I agree with you about "design." Just not sure about the trajectory of evolution. THere are a lot of dead-ends in the evolutionary paths. I suspect homo sapiens is just one of them.

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




















    Results (433 votes). Check out past polls.

    Notices?