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

Add table name to * in SQL here ;

$db{$tbl} = $dbh->selectall_arrayref("SELECT NE,$tbl.* FROM $tbl");
Seems that without table name Access interprets * as all fields not already specified.

poj

Replies are listed 'Best First'.
Re^4: Perl DBI
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:02 UTC

    Can u please explain this statement?what is the reason for placing the NE as the first column?

    arun

      So that you can filter the records here
      if (( $_->[0] eq $bsc ) && ( $_->[3] > $thresh )){
      poj
Re^4: Perl DBI
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:23 UTC

    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

      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