in reply to Re: Concurrent access to db2 and sybase databases
in thread Concurrent access to db2 and sybase databases

i think i wasnt able to define the problem clearly... i am getting the data locally in "@row" and then using this data as parameter for the subsequent query which accesses a different database on a different host .. the trouble is usage of two database handles... they dont work together ... if the 1st connection is open using $dbh1 the second connection cannot be opened using $dbh2 , i have close the connection and open a new connection on same database handle to prepare the the next query i would like to use different databse handles for each new connections i open
  • Comment on Re^2: Concurrent access to db2 and sybase databases

Replies are listed 'Best First'.
Re^3: Concurrent access to db2 and sybase databases
by roboticus (Chancellor) on Mar 26, 2008 at 21:20 UTC
    mayankshah:

    Oh, I see what you want. Yeah, you can't expect two databases to be able to share a single database connection. However, you can get the results you want using something like the (untested) bit below:

    $dbh1->connect("to db2 database"); $dbh2->connect("to sybase database"); $sth1=$dbh1->prepare("select apples, bananas from fruit_salad"); $sth2=$dbh2->prepare("insert snack (apples, bananas) values (?,?)"); $sth1->execute(); while (@row=$sth1->fetchrow_array()) { $sth2->execute(@row); }

    This way, you get the data out of your statement handle in a nice, simple array which you feed to your *other* statement handle.

    ...roboticus
      thanks it worked
      thanks a ton it worked