Re: array of composite types - how can I launch this function with an array of composite values - Mailing list pgsql-novice

From Tom Lane
Subject Re: array of composite types - how can I launch this function with an array of composite values
Date
Msg-id 2377.1223219478@sss.pgh.pa.us
Whole thread Raw
In response to array of composite types - how can I launch this function with an array of composite values  ("Nikita Koselev" <koselev@gmail.com>)
List pgsql-novice
"Nikita Koselev" <koselev@gmail.com> writes:
> SELECT * FROM add_position('{("name", "descr", "req_id", "req_type_id",
> "priority_id", "nec_id", 2.1321, 1.2323)}');

Parentheses are not part of the array-literal syntax.  You'd need
something more like
    '{"(\"name\", \"descr\", ...)"}'
and the backslashes would have to be doubled if this is an old-style
string literal.

Personally I'd avoid the thicket of quoting rules and build up the value
using SQL constructs:
    array[row('name', 'descr', ...)::requirement_vo, row(...), ...]
I think casting the first row() to the desired rowtype is probably
sufficient, though it might depend on which PG version you're using.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Richard Broersma"
Date:
Subject: Re: accessing composite value's field in function
Next
From: "Richard Broersma"
Date:
Subject: Re: DESCRIBE for composite type?