Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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.

Comment on Re^3: selectall_arrayref with headers
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970917]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2015-11-27 20:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls