in reply to Re^3: Perl DBI
in thread Perl DBI

SELECT * FROM $tbl; this statement also has the same effect? what is the differnce between your statement and the statement above?(may be in terms of performance)

arun

Replies are listed 'Best First'.
Re^5: Perl DBI
by poj (Abbot) on Jun 30, 2013 at 20:33 UTC

    If the first field of your tables is not NE then $_->[0] eq $bsc will not work. Using * is not recommended, apart from the performance issue you are at risk of a table change breaking your script.

    poj

      There are plenty ways to do it fast. The "best" way might be using a hash combined with bind_columns as described in the documentation:

      my $dbh = DBI->connect ($dsn, $user, $pass, { FetchHashKeyName => "NAM +E_lc", … }); my ($sth, %rec) = $dbh->prepare ("select * from $tbl"); $sth->execute; $sth->bind_columns (\(@rec{@{$sth->{NAME_lc}}})); while ($sth->fetch) { $rec{"ne"} eq $bsc or next; # All fields accessible by their name (lc) }

      Enjoy, Have FUN! H.Merijn