Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group