Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B255F475E25 for ; Wed, 2 Oct 2002 12:54:52 -0400 (EDT) Received: from asimov.az-informatique.com (ALyon-209-2-3-19.abo.wanadoo.fr [193.251.9.19]) by postgresql.org (Postfix) with ESMTP id 0CD6F475D12 for ; Wed, 2 Oct 2002 12:54:52 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by asimov.az-informatique.com (Postfix) with ESMTP id 648BF140A7; Wed, 2 Oct 2002 18:54:35 +0200 (CEST) Received: from localhost.localdomain (ghost.az-informatique.com [192.168.1.56]) by asimov.az-informatique.com (Postfix) with ESMTP id A6D2F5C84; Wed, 2 Oct 2002 18:54:31 +0200 (CEST) Subject: Re: split function for pl/pgsql From: Frederic Logier To: Joe Conway Cc: pgsql-sql@postgresql.org In-Reply-To: <3D9B1479.2060600@joeconway.com> References: <1033554614.16115.45.camel@ghost> <3D9B1479.2060600@joeconway.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable X-Mailer: Ximian Evolution 1.0.8 Date: 02 Oct 2002 18:54:58 +0200 Message-Id: <1033577699.14486.81.camel@ghost> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS perl-11 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/18 X-Sequence-Number: 9736 Le mer 02/10/2002 =E0 17:44, Joe Conway a =E9crit : > There is no split function built in to PostgreSQL currently. You could wr= ite=20 > it yourself in PL/Perl and use it in the PL/pgSQL function. Great ! have you some example for call a pl/perl function from a pl/pgsql function ? And could i use an int array in pl/pgsql returned by the pl/perl function ? > In 7.3 (currently in beta) there is a split_part() function which returns= just=20 > one element. I will most likely write a split function for 7.4 to return = an=20 > array, similar to perl and php. In 7.3, the following will do what you wa= nt (I=20 > think): Thanks for your function but i can't use a beta version of postgresql in production :( maybe i should use a int array like this example : create function foo(_int4) returns int2 as' declare a alias for $1; i int:=3D1; begin while a[i] loop i:=3Di+1; end loop; return i-1; end; ' language 'plpgsql'; you can call it by: select foo('{1232131,12312321,3424234}'); --=20 AZ informatique 68 avenue Felix Faure 69003 Lyon Tel : +33 (0) 472 844 949 direct : +33 (0) 472 844 956 Fax : 04 78 60 40 70