Ammu has asked for the wisdom of the Perl Monks concerning the following question:
Our requirement is to fetch some rows from a database table and put it in a new hashtable with a specified column as key.
When i am using Dumper i will be able to get all tha entries for hashtable.But what if i need to get the value corresponding to a certain key. I tried print "@{$hash{'E200'}}\n"; This if for printing the values corresponding to the id E200.But its not showing any output.Please help.$dbh = DBI->connect("dbi:ODBC:Driver={SQL Server};Server=<Servername>; +UID=<username>;PWD=<pswd>") ; my $sth = $dbh->prepare("select id,name,job,location from <databasenam +e>.employee_relation"); $sth->execute; my $hash = $sth->fetchall_hashref('id'); print Dumper($hash);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of fetchall_hashref
by choroba (Cardinal) on Sep 07, 2012 at 12:06 UTC | |
|
Re: Use of fetchall_hashref
by Corion (Patriarch) on Sep 07, 2012 at 12:14 UTC | |
|
Re: Use of fetchall_hashref
by runrig (Abbot) on Sep 07, 2012 at 14:47 UTC | |
by Anonymous Monk on Sep 10, 2012 at 04:16 UTC | |
by runrig (Abbot) on Sep 10, 2012 at 16:25 UTC | |
|
Re: Use of fetchall_hashref
by philiprbrenan (Monk) on Sep 07, 2012 at 13:12 UTC | |
|
Re: Use of fetchall_hashref
by frozenwithjoy (Priest) on Sep 07, 2012 at 21:29 UTC | |
|
Re: Use of fetchall_hashref
by Ravi V (Scribe) on Sep 07, 2012 at 15:20 UTC |