Re: Splitting text column to multiple rows - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Splitting text column to multiple rows
Date
Msg-id 162867791003290736l3a90d7e7l2b7763e5e547cea6@mail.gmail.com
Whole thread Raw
In response to Re: Splitting text column to multiple rows  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: Splitting text column to multiple rows  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
2010/3/29 Andrus <kobruleht2@hot.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@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.
>

pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Re: Splitting text column to multiple rows
Next
From: Dimitri Fontaine
Date:
Subject: Re: optimizing import of large CSV file into partitioned table?