Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: DBI weirdness: Arrays as strings. (ROW constructor)

by erix (Vicar)
on May 06, 2012 at 05:51 UTC ( #969113=note: print w/replies, xml ) Need Help??

in reply to DBI weirdness: Arrays as strings.

Yeah, there is no weirdness here. Parentheses make a regular select-list into a ROW-constructor (see the FM: "The key word ROW is optional when there is more than one expression in the list." ):

So it is:

testdb=# select x,y,z from (values ('abc', 'def', 'ghi')) as f(x,y,z); x | y | z -----+-----+----- abc | def | ghi (1 row)

but with parentheses:

testdb=# select (x,y,z) from (values ('abc', 'def', 'ghi')) as f(x,y,z +); row --------------- (abc,def,ghi) (1 row) -- also: -- "The key word ROW is optional when there is more than one expressio +n in the list." -- testdb=# select (x,y,z) = row(x,y,z) from (values ('abc', 'def', 'ghi')) as f(x,y,z); ?column? ---------- t (1 row)

(latest postgresql 9.1.3.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969113]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-02-24 04:00 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (351 votes). Check out past polls.