Re: Convert of string to array problem

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Convert of string to array problem
Дата
Msg-id s2wb42b73151004290559ua67f2bc0k2bb9ac3d735d91a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Convert of string to array problem  (Thom Brown <thombrown@gmail.com>)
Список pgsql-general
On Thu, Apr 29, 2010 at 8:52 AM, Thom Brown <thombrown@gmail.com> wrote:
> On 29 April 2010 13:35, Bård Grønbech <baard.gronbech@gmail.com> wrote:
>>
>> Have a string like '0.1;0.2;null;0.3' which I would like to convert
>> into a double precision[] array.
>>
>> Trying:
>>
>> select cast (string_to_array('0.1;0.2;null;0.3', ';') as float8[])
>>
>> gives me an error: invalid input syntax for type double precision: "null".
>>
>> Can anybody help me?
>>
>> -Bård
>>
>
> I believe string_to_array will take that null as a string called 'null',
> which it can't convert to a float8.

select array(select case when n='null' then null else n end from
unnest(string_to_array('0.1;0.2;null;0.3', ';')) as n);

?column?
--------------------
 {0.1,0.2,NULL,0.3}

merlin

В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Problem: concat an array of arrays
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: FW: Java Memory Issue while Loading Postgres library