I'm afraid that doesn't work for me, ysth. 'selectall' rather than 'selectcol' is the deal-killer here (I don't see the need for fetching the entire content of that table, extracting the columns, and then doing all this processing.)
This gets me exactly the info I need - although the structure is a little different from what I want:
my @ref = @{
$dbh->selectcol_arrayref(
"select date, label, subject from travel
where date>= curdate()-5 order by date",
{Columns=>[1,2,3]}
)
};
I do indeed appreciate your attempt to approach it from a broader viewpoint - I try not to lose track of the fact that stepping back can be as important as focusing down when trying to solve a problem. [Grin] Hell, my wife is Japanese-American. She'd beat my butt if I was ever so silly as to lose track of context.
| [reply] [d/l] |
I'm not understanding you at all. There's either something I'm missing or something you are. selectcol_arrayref and selectall_hashref will both read all the available rows. Yes, selectcol_arrayref by default throws away all but the first column, but in your invokation, you are telling it to keep all three columns.
| [reply] |
(Sorry for the long delay; I got bushwhacked by Real Life, but managed to survive it.)
I'd tried using selectall_hashref originally - that is, in fact, the first approach I tried - but I recall being unsatisfied with the output. I just went back and reproduced what I'd done then, and the problem turns out to be that either the docs don't tell you how to do what I need to do, or it just can't be done with selectall_hashref. In short, here are the problems:
1) Remapping that hashref into the arrayref that I want isn't any easier than what I was looking for - unless I've missed something.
2) The output format is... graceless. Perhaps it is, as you say, that I'm missing something - but I want two columns as an arrayref keyed by date, and what selectall_hashref returns is
'2007-05-13' => {
subject => 'foobar',
date => '2007-05-13', # Erm...
label => 'xyz'
}
The statement that I'm using is one I showed previously:
my $ref = $dbh->selectcol_arrayref(
"select date, label, subject from travel where date >= curdate()-5
+ order by date",
{ Columns=>[1,2,3] }
);
If you can show me how to do this better with selectall_hashref, I'd be grateful.
| [reply] [d/l] [select] |