Re: [Q] parsing out String array - Mailing list pgsql-general

From Sam Mason
Subject Re: [Q] parsing out String array
Date
Msg-id 20090815201731.GR5407@samason.me.uk
Whole thread Raw
In response to Re: [Q] parsing out String array  ("V S P" <toreason@fastmail.fm>)
Responses Re: [Q] parsing out String array
List pgsql-general
On Sat, Aug 15, 2009 at 01:41:12PM -0400, V S P wrote:
>  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[][]

Not sure what you tried, but the following does the "right" thing for
me:

  SELECT ('{{A,B,C},{D,E,F}}'::text[])[1][1];

The brackets are needed so that PG doesn't get confused between the type
declaration and the array indexing.

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: "V S P"
Date:
Subject: Re: [Q] parsing out String array
Next
From: Madison Kelly
Date:
Subject: A history procedure that prevents duplicate entries