Newbie request
From: Robert Follett (robert.follett_at_Vanderbilt.Edu)
Date: 12/16/04
- Next message: Andy Hassall: "RE: Win98 - DBD-Oracle install issue"
- Previous message: Jeff Urlwin: "RE: cross-posted FAQ question [was: Win98 - DBD-Oracle install issue]"
- Next in thread: Ron Reidy: "RE: Newbie request"
- Maybe reply: Ron Reidy: "RE: Newbie request"
- Maybe reply: Hardy Merrill: "RE: Newbie request"
- Maybe reply: Ron Reidy: "RE: Newbie request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
}
}
- Next message: Andy Hassall: "RE: Win98 - DBD-Oracle install issue"
- Previous message: Jeff Urlwin: "RE: cross-posted FAQ question [was: Win98 - DBD-Oracle install issue]"
- Next in thread: Ron Reidy: "RE: Newbie request"
- Maybe reply: Ron Reidy: "RE: Newbie request"
- Maybe reply: Hardy Merrill: "RE: Newbie request"
- Maybe reply: Ron Reidy: "RE: Newbie request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|