From: | "Andrus" <kobruleht2(at)hot(dot)ee> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Splitting text column to multiple rows |
Date: | 2010-03-29 15:08:15 |
Message-ID: | C0A3EB70B9C347DF863C660F33ADE4E3@andrusnotebook |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I changed unction name and tried:
CREATE OR REPLACE FUNCTION unnest21(anyarray)
RETURNS SETOF anyelement as $$
SELECT $1[i] FROM generate_series(1,4) g(i)
$$ LANGUAGE sql;
select unnest21(string_to_array('23,2,3,4,5',','));
In this case it returns only 4 rows.
No idea what is happening.
Andrus.
----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrus" <kobruleht2(at)hot(dot)ee>
Cc: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>;
<pgsql-general(at)postgresql(dot)org>
Sent: Monday, March 29, 2010 6:00 PM
Subject: Re: [GENERAL] Splitting text column to multiple rows
> "Andrus" <kobruleht2(at)hot(dot)ee> writes:
>> Pavel,
>>> 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.
>
> Surely that's a copy-and-paste mistake? I get 5 rows from this example.
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Leif Biberg Kristensen | 2010-03-29 15:09:25 | Re: insert into test_b (select * from test_a) with different column order |
Previous Message | Andrus | 2010-03-29 15:02:42 | Re: Splitting text column to multiple rows |