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

Re: Convert of string to array problem

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Thom Brown <thombrown(at)gmail(dot)com>
Cc: Bård Grønbech <baard(dot)gronbech(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Convert of string to array problem
Date: 2010-04-29 12:59:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Thu, Apr 29, 2010 at 8:52 AM, Thom Brown <thombrown(at)gmail(dot)com> wrote:
> On 29 April 2010 13:35, Bård Grønbech <baard(dot)gronbech(at)gmail(dot)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);



In response to

pgsql-general by date

Next:From: Craig RingerDate: 2010-04-29 13:03:54
Subject: Re: FW: Java Memory Issue while Loading Postgres library
Previous:From: Merlin MoncureDate: 2010-04-29 12:53:39
Subject: Re: Problem: concat an array of arrays

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