Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

In reply to prepare statement within DBI by Paulster2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found