simple query question to use with DBI selectall_hashref

Поиск
Список
Период
Сортировка
Искать
От
Kenji Morishige
Тема
simple query question to use with DBI selectall_hashref
Дата
Msg-id
20070705173931.GA28680@juniper.net
Список
Дерево обсуждения
simple query question to use with DBI selectall_hashref Kenji Morishige <kenjim@juniper.net>
Re: simple query question to use with DBI selectall_hashref Martijn van Oosterhout <kleptog@svana.org>
I would like to create a query that returns a column with an integer
1 through (row_count) to use as the index while used in conjunction with
DBI's selectall_hashref($sql,$key) function.  In the past I'd usually just
write a wrapper around selectrow_hashref and put all those results in an
array. I don't know why DBI doesn't include a function like this.

if I could extract a pseudo column from the query itself with the result
order number, I could just use that as the key in selectall_hashref and sort
the results by key.

Is there a built-in function that returns the current row #?

select foo from bar;
row#;foo
----;-----
1;foodata1 
2;foodata2 
3;foodata3 
4;foodata4 

so I can pump it into:
my $hashref = $dbh->selectall_hashref($query);

print $hashref->{1}; # prints 'foodata1' etc

Or am I missing something and there is a way better way to do this...?

Sincerely,
Kenji
В списке pgsql-general по дате отправления
От: A.M.
Дата:
От: Nykolyn, Andrew
Дата:
FAQ