Search Postgresql Archives

Re: Varchar -> Integer[] conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux