Skip site navigation (1) Skip section navigation (2)

Re: Splitting text column to multiple rows

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Splitting text column to multiple rows
Date: 2010-03-29 14:36:09
Message-ID: 162867791003290736l3a90d7e7l2b7763e5e547cea6@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
2010/3/29 Andrus <kobruleht2(at)hot(dot)ee>:
> Pavel,
>
>> CREATE OR REPLACE FUNCTION unnest(anyarray)
>> RETURNS SETOF anyelement as $$
>>  SELECT $1[i] FROM generate_series(1,4) g(i)
>> $$ LANGUAGE sql;
>>
>> pavel(at)postgres:5481=# select unnest(string_to_array('23,2,3,4,5',','));
>> unnest
>> --------
>> 23
>> 2
>> 3
>> 4
>> (4 rows)
>
> Result is wrong: it must contain 5 rows.
> How to make this work with with any array size ?

CREATE OR REPLACE FUNCTION unnest(anyarray)
RETURNS SETOF anyelement as $$
 SELECT $1[i] FROM
generate_series(array_lower($1,1),array_upper($1,1)) g(i) -- there was
error
 $$ LANGUAGE sql;

regards
Pavel
>
> Some lines are long.
> How to implement word wrap to new row in 80th position but between words
> only ?
>
> Andrus.
>

In response to

Responses

pgsql-general by date

Next:From: 赤松 建司Date: 2010-03-29 14:43:20
Subject: help
Previous:From: AndrusDate: 2010-03-29 14:27:17
Subject: Re: Splitting text column to multiple rows

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group