converting 1 dimensional array to 2 dimensional array

From: Nicholas Wilson <nwilson5(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: converting 1 dimensional array to 2 dimensional array
Date: 2012-03-12 20:31:42
Message-ID: CABgBcYO=PCP_pP+_hk_ZYQ6gACrQ7fzJe8__xfWg3OCX5wGSoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi, need help with some syntax.

Currently we have a column of type text[]. It is a 1 dimensional array of
text values. Each of them we have formatted in such a way that it can be
split into two values. We are trying to convert it into a two dimensional
array but are unsure how to do that.

i.e. converting:
{a^^val1, b^^val2, c^^val3}
to
{{a,val1}, {b,val2}, {c,val3}}

I can do
Select array(select '{"' || replace(unnest(col1), '^^', '","') || '"}')
from table;

But that still gives me one dimensional text array. I can't cast it to
text[] because there are no array of arrays. How do I get this into a 2
dimensional array?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message John 2012-03-13 05:01:50 Warning console code page (437) differs from Window code page (1252)
Previous Message Gavin Flower 2012-03-10 19:38:24 Re: When to choose putting logic into PL/pgSQL and when to use an app server