Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Think about Loose Coupling
 
PerlMonks  

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

by Corion (Pope)
on May 07, 2009 at 06:32 UTC ( #762495=note: print w/ replies, xml ) Need Help??


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

How would we know without seeing your code?

My guess is that Connection is busy with result means that you still have a statement handle open and did not ->finish() it before trying to issue another SQL statement.

Update: Now, actually reading your title, the answer is "no, not with the DBD you're using, it seems".


Comment on Re: Can i execute two queries connecting to same DB at a time.
Select or Download Code
Re^2: Can i execute two queries connecting to same DB at a time.
by afoken (Parson) on May 07, 2009 at 06:50 UTC

    Right. MS SQL Server can handle only one active connection without sacrificing some chickens. This is a limitation of the communication protocol between the ODBC driver and the MS SQL Server, not a DBI or DBD::ODBC limitation, and it is documented in DBD::ODBC::FAQ. Other RDBMS like Oracle and PostgreSQL can handle multiple active connnections via DBI without any problems, at least with their native DBDs, but they should also support them with DBD::ODBC and a recent ODBC driver.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Below is the my code my ( $data_source, $user_id, $password ) = qw( PHOENIX DBADMIN DBADMIN ); my $conn_string = "driver={SQL Server};Server=$data_source;Database=$database;UID=$user_id;PWD=$password"; my $dbh = DBI->connect( "DBI:ODBC:$conn_string" ) or die $DBI::errstr; my $sql1 = "SELECT CONTENT_HASH FROM DS_STAGING_CONTENTHASH where STAGING_STATUS_GID!=210"; my $sth = $dbh->prepare( $sql1 ); $sth->execute; In this i executed only one query (above code works fine). But when i try to execute another query by my $sql2 = "SELECT CASESHARE_PATH FROM DS_CASESHARE"; my $sth2 = $dbh->prepare( $sql2 ); $sth2->execute; This gives error as i mentioned above

        Please use <code> tags, this is unreadable. And read what I wrote about the protocol issue just five minutes ago.

        Alexander

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

        What part of Connection is busy with result and my reply:

        you still have a statement handle open and did not ->finish() it before trying to issue another SQL statement
        is giving you problems?

        Your code is opening a second SQL statement before retrieving all results from the first SQL statement. This does not work for your combination of database, OS and DBD.

Re^2: Can i execute two queries connecting to same DB at a time.
by bingohighway (Acolyte) on May 07, 2009 at 09:57 UTC
    I have done something similar but I used multithreading. It didn't seem to cause a problem that way.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-04-21 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls