Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am new to perl and would appreciate some pointers on how to improve my db access code. I have some code below to get all rows from a table, select their value for a particular column and then delete any other rows that have that value. I know i could use a more efficient sql query but the more effient query was really slow and this is faster. I was wondering how i should improve my db access code:
I was also wondering if there were any problems with getting more than one statement handler off the same database connection?my $sql_select = "select * from $tableName"; my $sth = $db->do($str_select); $sql_delete = "delete from $tableName where LiftChr=? and Lift +Pos=?"; my $sth1 = $db->prepare($sql_delete); while ($snp = $sth->fetchrow_hashref) { $sth1->execute($sql_delete, undef, $snp->{'LiftChr'}, $snp-> +{'LiftPos'}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cleaning up dbi code
by Corion (Patriarch) on Nov 26, 2010 at 17:15 UTC | |
by Anonymous Monk on Nov 26, 2010 at 19:35 UTC | |
by Corion (Patriarch) on Nov 26, 2010 at 19:44 UTC | |
by Anonymous Monk on Nov 26, 2010 at 19:49 UTC | |
by Corion (Patriarch) on Nov 26, 2010 at 19:55 UTC | |
by roboticus (Chancellor) on Nov 26, 2010 at 23:09 UTC | |
|
Re: cleaning up dbi code
by mje (Curate) on Nov 26, 2010 at 17:26 UTC | |
by Anonymous Monk on Nov 26, 2010 at 19:37 UTC | |
by Anonymous Monk on Nov 26, 2010 at 19:50 UTC | |
by ruzam (Curate) on Nov 27, 2010 at 04:18 UTC | |
by roboticus (Chancellor) on Nov 26, 2010 at 23:11 UTC |