From: | "V S P" <toreason(at)fastmail(dot)fm> |
---|---|
To: | "postgres general" <pgsql-general(at)postgresql(dot)org>, "Scott Bailey" <artacus(at)comcast(dot)net> |
Subject: | Re: [Q] parsing out String array |
Date: | 2009-08-15 17:41:12 |
Message-ID: | 1250358072.6935.1330005033@webmail.messagingengine.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you very much , your suggestion
helped a lot
But, I have a bit more of a challenge now,
my array is being generated by the 'client' (it is not in the database)
so I am trying to employ your method on
'string'
but running into a problem as I cannot typecast correctly
select V[i][j]
FROM
(select '{{A,B,C},{D,E,F}}') as V
CROSS JOIN generate_series(1, 3) i
CROSS JOIN generate_series(1,2) j
Does not work, because V is not an array (it is a string)
and I do not know where to put the typecast
::text[][]
anywhwere I tried I get syntax error
thank you in advance for help
>
> On Wed, 12 Aug 2009 20:52 -0700, "Scott Bailey" <artacus(at)comcast(dot)net>
> wrote:
> > 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
> >
--
Vlad P
author of C++ ORM http://github.com/vladp/CppOrm/tree/master
--
http://www.fastmail.fm - Accessible with your email software
or over the web
From | Date | Subject | |
---|---|---|---|
Next Message | Emanuel Calvo Franco | 2009-08-15 18:25:50 | Re: uuid contrib don't compile in OpenSolaris |
Previous Message | Alvaro Herrera | 2009-08-14 22:10:49 | Re: licensing/distribution of DLL's question |