tomazos has asked for the wisdom of the Perl Monks concerning the following question:
I want to select a set of items by ids on some predicate '--PREDICATE--' from an SQL table via DBI.
The long way:
use DBI; my $dbh = DBI->connect(...); .... my @ids = (); my $sth = $dbh->prepare('select id from items where '--PREDICATE-- +'); $sth->execute(); while (my ($id) = $sth->fetchrow_array()) { push @ids, $id; } $sth->finish(); ....
I want a shorter one line version.
I am sure there exists some neat contortion using $dbh->select(col|row|all)_(array|hash)(ref)? and referencing/dereferencing - I just can't see it (and am no good with arrays of hash of reference to hash list tap dancing -- $ref->2<-{3,4}[0]{2} -- :P )
-Andrew.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI select ids to @ids
by rnahi (Curate) on Aug 10, 2005 at 07:11 UTC | |
|
Re: DBI select ids to @list
by ikegami (Patriarch) on Aug 10, 2005 at 05:31 UTC | |
by tomazos (Deacon) on Aug 10, 2005 at 05:43 UTC | |
by ikegami (Patriarch) on Aug 10, 2005 at 05:52 UTC | |
|
Re: DBI select ids to @ids
by mifflin (Curate) on Aug 10, 2005 at 05:38 UTC | |
by tomazos (Deacon) on Aug 10, 2005 at 05:47 UTC | |
by mifflin (Curate) on Aug 10, 2005 at 06:17 UTC | |
by tomazos (Deacon) on Aug 10, 2005 at 07:25 UTC |