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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nikita Koselev" <koselev(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: array of composite types - how can I launch this function with an array of composite values
Date: 2008-10-05 15:11:18
Message-ID: 2377.1223219478@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Nikita Koselev" <koselev(at)gmail(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma 2008-10-05 15:13:17 Re: DESCRIBE for composite type?
Previous Message Richard Broersma 2008-10-05 14:58:33 Re: accessing composite value's field in function