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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.