http://qs321.pair.com?node_id=385694

Paulster2 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to figure out a better way of doing this. The following code works just fine, but am wondering how to do it better, ie: Can I put both sql statements within the same prepare statement? Will it even make that big of a difference? Is the real time spent in the connection of the DB vs the actual time spent on the queries? : (Please forgive typo's as I have to retype from another system!)

use DBI; $dsn = "dbi:Oracle:host=<ip withheld>;sid=ORA8I;port=1521"; $user = "<data withheld>"; $password = "<data withheld>"; $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 1}); $sth = $dbh->prepare("select count(*) from table_one"); $sth->execute(); $row1 = $sth->fetchrow_array; $sth = $dbh->prepare("select count(*) from table_two"); $sth->execute(); $row2 = $sth->fetchrow_array; print "$row1, $row2 \n"; $sth->finish(); $dbh->disconnect();

It seems that if I could combine the two sql statements into one statement that it would help it function cleaner. Mind you that with just two statements, it's not going to make much of a difference, but if I want to make it more complicated, it has the potentiality of creating a big diffence, at least to my way of thinking.

I have checked on SuperSearch, which I believe that the answer is there. I just don't seem to be coming up with the combination of parameters in order to find what I need. Hoping someone out here has a suggestion.

Thanking you all in advance ;-)

Paulster2


You're so sly, but so am I. - Quote from the movie Manhunter.