Converting value to array

From: "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Converting value to array
Date: 2005-02-05 16:12:09
Message-ID: 001201c50b9d$71c93570$7d75f345@WATSON
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have a column in my table block_sizes(varchar) that looks like:

12,23,
234,23,
78,64,28,

i.e., comma-separated integer values (and the included trailing comma). I would like to convert these each to an array and store in another column. However, I haven't been able to get this to work. I have tried things like:

array[rtrim(block_sizes,',')]
'''' || '{' || rtrim(block_sizes,',') || '}' || ''''::int[]
'{' || rtrim(block_sizes,',') || '}'

as expressions in an update to the new column (declared as int[]). However, it seems as if the result of the rtrim is treated differently than the same expression entered directly. Can someone enlighten me as to how to make this conversion?

Thanks,
Sean

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-02-05 16:41:47 Re: Converting value to array
Previous Message Bruno Wolff III 2005-02-05 16:00:48 Re: Help with subselect (first time)