Re: Looping through string constants

From: Scott Bailey <artacus(at)comcast(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Looping through string constants
Date: 2009-08-13 03:45:58
Message-ID: 4A838C76.3040806@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>> Using arrays makes it a little less verbose and easier to manage IMO.
>>
>> SELECT v FROM unnest(array['a','b','c','d']) v
>>
>
> Is that 8.4? or is unnest from contrib/ ?
>
> thanks!
>
> Dave

Unnest is included in 8.4, but it's pretty much essential for working
with arrays. Pre 8.4, you'd add the function like so

CREATE OR REPLACE FUNCTION unnest(anyarray)
RETURNS SETOF anyelement AS
$BODY$
SELECT $1[i] FROM
generate_series(array_lower($1,1),
array_upper($1,1)) i;
$BODY$
LANGUAGE 'sql' IMMUTABLE STRICT

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Bailey 2009-08-13 03:52:17 Re: [Q] parsing out String array
Previous Message V S P 2009-08-13 03:40:54 [Q] parsing out String array