Re: [Q] parsing out String array

From: Scott Bailey <artacus(at)comcast(dot)net>
To:
Cc: postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: [Q] parsing out String array
Date: 2009-08-13 03:52:17
Message-ID: 4A838DF1.5030002@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

V S P wrote:
> if I have field declared
> myvalue text[][]
>
> insert into vladik (myval)
> values
> (
> '{{"\",A", "\"B"}, {"Y", "Q"}}'
> )
>
>
> What do you guys use in your treasurechest of 'addons'
> to successfully parse out the above trickery
> and get
>
> and get the 4 strings
> ",A
> "B
> Y
> Q
>
> from within Postgres stored procedure as well as C++ or other client
> code.
>
>
> It seems to me that it is not possible with any built-in command
> available
> to easily extract the strings out to a multidimensional array

Actually its pretty easy.

SELECT myval[i][j]
FROM vladik
CROSS JOIN generate_series(1, array_upper(myval, 1)) i
CROSS JOIN generate_series(1, array_upper(myval, 2)) j

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message arsi 2009-08-13 06:09:05 Encoding question when dumping/restoring databases for upgrade
Previous Message Scott Bailey 2009-08-13 03:45:58 Re: Looping through string constants