Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: selectall_arrayref with headers

by Corion (Pope)
on May 16, 2012 at 20:31 UTC ( #970917=note: print w/replies, xml ) Need Help??


in reply to Re^2: selectall_arrayref with headers
in thread selectall_arrayref with headers

The Slice => {} option retrieves all column names for each row, as it returns hashes. You can then use these as the keys.

An (somewhat ugly) alternative is to add WHERE 1 = 0 to the query and run it and afterwards ask the statement handle for the names of its columns. This has the advantage of keeping all columns in the same order as the select clause, but has the disadvantage of needing to shim the clause into an existing string.

DBI has more on the topic.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970917]
help
Chatterbox?
[choroba]: Yes, I feel alone in the cyberspace...
[choroba]: Not many occasions to talk to my wife, either :-(
Discipulus s/silbing/whistle/ dunno from where this word was in my mind..
[Discipulus]: lost in time in space and in the meaning (rocky horror picture show)
[Corion]: Discipulus: Yeah, a short vacation on the Canary islands (Lanzarote). Always great to be in the warmth and sun, from a cold and rainy February here ;)
[Corion]: choroba: Yeah, you have to find a time for the regular skype (or whatever) meetup, I imagine that's hard
[choroba]: Lanzarote is great!
choroba went there year ago

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2017-02-22 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (325 votes). Check out past polls.