Newbie request

From: Robert Follett (robert.follett_at_Vanderbilt.Edu)
Date: 12/16/04


Date: Thu, 16 Dec 2004 16:29:55 -0600
To: <dbi-users@perl.org>

 I am a total perl newbie and was wondering if someone could take a look
at my code to determine if I am doing this the most efficient way. It
works as it should, but I am sure an expert out there may have some
constructive comments to help me make it better.
 
For a little background: I am pulling some ids from a MySQL table into
an array, then connecting to Oracle and pulling lab information based on
the id's in the array. The lab info will then be loaded back into
MySQL.
 
Thanks in advance for any time you have to look at this.
 
 
$sql = "SELECT mbr_no, mrn, make8mrn FROM make8mrn";
 my $sth = $dbh->prepare($sql);
 $sth->execute();

 while (my @data = $sth->fetchrow_array()) {
  push @hold_mrns, [@data];
 }
 
 #Connect to Oracle db
  my $OraDBH = DBI->connect("DBI:Oracle:ourdb",$user,$pwd , {RaiseError
=> 1});
 
 
 #Build date parms
 (my $yyyy, my $mm, my $dd) = Today();
 my $sql_to_date = "to_date('" . sprintf("%02d", $mm ) . sprintf("%02d",
$dd) . "$yyyy','MM/DD/YYYY')";
 ($yyyy, $mm, $dd) = Add_Delta_YMD(Today(), 0, -6, 0);
 my $sql_from_date = "to_date('" . sprintf("%02d", $mm ) .
sprintf("%02d", $dd) . "$yyyy','MM/DD/YYYY')";
 
 $sql = "SELECT COLLECTION_DATE, TEST, RESULT FROM LABTABLE" .
     "WHERE (MRN = ? AND COLLECTION_DATE >= $sql_from_date AND
COLLECTION_DATE <= $sql_to_date " .
     "AND (TEST = 'HgbA1C' OR TEST = 'Chol'))";
 
    $sth = $OraDBH->prepare_cached($sql);
    
 #Get lab info from Oracle
 for my $aref ( @hold_mrns ) {
        get_labs($OraDBH, $sth, @$aref[2]);
    }
}

 
sub get_labs {
 my ($dbh, $sth, $mrn) = @_;
 
 my @hold_labs;
 $sth->execute($mrn);
 while (my @data = $sth->fetchrow_array()) {
  push @hold_labs, [@data];
 }
 
 for my $aref ( @hold_labs ) {
   #Load this into mySQL
 }
}



Relevant Pages

  • Re: OT: How I learned to stop worrying and love the RDBMS
    ... not used either to replace TurboIMAGE for a migration client. ... Oracle and DB2 to replace TurboIMAGE for migration clients and our partners ... MySQL has become. ... The primary reason for our Oracle, DB2 and MS SQL Server emphasis is because ...
    (comp.sys.hp.mpe)
  • Re: Table open times and rowsize discontinuity
    ... some manner related to ADO or the tool you are using. ... Puget Sound Oracle Users Groupwww.psoug.org- Hide quoted text - ... For the array fetching, the only parameter I can find in the ADO ... exceeding the SDU and the MTU. ...
    (comp.databases.oracle.misc)
  • Re: MySQLdb slow on MySQL 5
    ... Oracle bought a small Finnish ... company which developed the transaction-aware table- ... backend for MySQL. ... It's one thing if Oracle fails to comply to all standards, ...
    (comp.lang.python)
  • Re: Oracle vs MySql Performance
    ... Performance on MySql was adequate but as our primary DB platform is ... Oracle we influenced the 3rd part to introduce an Oracle version (NB: ... To facilitate this process the vendor has used almost pure ANSI Sql so ... Look at the wait events in the raw trace file for clues ...
    (comp.databases.oracle.server)
  • Re: Select count(*) in Oracle and MySQL
    ... The same query in Oracle takes about 6 minutes, ... The MySQL table has no primary key either. ... you either don't know how to use a DBMS like Oracle (given ...
    (comp.databases.oracle.server)