Search Postgresql Archives

simple query question to use with DBI selectall_hashref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux