Gustavo Tonini wrote:
> Someone have a function that converts a string literal (a varchar
> argument) to an integer array?
It isn't clear from your question if you want this:
select string_to_array('1,2,3'::varchar,',')::int[];
string_to_array
-----------------
{1,2,3}
(1 row)
or this:
select array['1'::varchar]::int[];
array
-------
{1}
(1 row)
or this:
select array(select '1'::varchar)::int[];
int4
------
{1}
(1 row)
or maybe this:
select ('{}'::varchar[] || '1'::varchar)::int[];
int4
------
{1}
(1 row)
Please provide more detail on what you need to accomplish.
Joe