Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by afoken (Parson)
on May 07, 2009 at 14:51 UTC ( #762627=note: print w/ replies, xml ) Need Help??


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

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". ;-)


Comment on Re^2: Can i execute two queries connecting to same DB at a time.
Download Code
Re^3: Can i execute two queries connecting to same DB at a time.
by tilly (Archbishop) on May 07, 2009 at 20:34 UTC
    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.

Re^3: Can i execute two queries connecting to same DB at a time.
by Jenda (Abbot) on May 08, 2009 at 00:37 UTC

    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". ;-)

        I don't buy your definition of "proper RDBMS", it's way too ad hoc. Made up just to allow you to bash MSSQL. MS SQL has the communication protocol optimized for the common case, "you ask for data, you fetch the data, you ask for some other data, you fetch that data". The requirement of the special coding is caused more by the fact that there is no DBD::MSSQL, but rather a generic DBD::ODBC that has to support a lot more than just the MSSQL. So it cannot transparently handle the more complex cases.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-11-28 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (200 votes), past polls