Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 1431B9FB4C8 for ; Thu, 12 Oct 2006 20:00:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 85553-09 for ; Thu, 12 Oct 2006 23:00:49 +0000 (UTC) X-Greylist: delayed 00:45:44.861388 by SQLgrey- Received: from fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id 0812D9FB4C9 for ; Thu, 12 Oct 2006 20:00:48 -0300 (ADT) Received: from [157.92.155.58] (unknown [157.92.155.58]) by fmed.uba.ar (Postfix) with ESMTP id C25F9419BD0; Thu, 12 Oct 2006 20:06:52 -0300 (ART) Message-ID: <452EC91D.1050206@fmed.uba.ar> Date: Thu, 12 Oct 2006 20:00:45 -0300 From: Gerardo Herzig User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bricklen Anderson CC: pgsql-sql@postgresql.org Subject: Re: spliting a row to make several rows References: <452EBF1F.7070505@fmed.uba.ar> <452EC4E4.90107@presinet.com> In-Reply-To: <452EC4E4.90107@presinet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200610/122 X-Sequence-Number: 26511 Cool!! Thanks a lot! I will try it as soon as possible Gerardo > Gerardo Herzig wrote: > >> Hi all: What a want to do is something like this: >> suppose i have this record >> >> aa--bb--cc >> >> I guess if im able to do some sql/plsql procedure to get something >> like it >> aa >> bb >> cc >> (3 records, rigth?) >> >> Thanks a lot >> Gerardo >> > > dev=#select split_to_rows('aa--bb--cc','--'); > > split_to_rows > --------------- > aa > bb > cc > (3 rows) > > > This function was written by David Fetter, > http://archives.postgresql.org/pgsql-general/2005-12/msg00080.php > > CREATE OR REPLACE FUNCTION split_to_rows(TEXT,TEXT) RETURNS SETOF TEXT > AS $$ > SELECT (string_to_array($1, $2))[s.i] > FROM generate_series( > 1, > array_upper(string_to_array($1, $2), 1) > ) AS s(i); > $$ language sql strict; > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > >