From me@oisinglynn.com Sat Feb 26 17:49:23 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DBF425638A for ; Sat, 26 Feb 2005 17:49:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20013-09 for ; Sat, 26 Feb 2005 17:49:15 +0000 (GMT) Received: from ns.saturnnet.co.uk (ns.saturnnet.co.uk [217.199.174.12]) by svr1.postgresql.org (Postfix) with ESMTP id A852856666 for ; Sat, 26 Feb 2005 17:49:20 +0000 (GMT) Received: from boole ([64.213.65.29]) by ns.saturnnet.co.uk (8.10.2/8.10.2) with ESMTP id j1QHnHa21443 for ; Sat, 26 Feb 2005 17:49:17 GMT Message-ID: <006f01c51c2c$54fb6ef0$a974fea9@homisco.local> From: "Oisin Glynn" To: References: <200502241717.14648.aarni@kymi.com> <1109424259.10941.6.camel@localhost.localdomain> Subject: Reverse String in sql or pgplsql Date: Sat, 26 Feb 2005 12:55:11 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_006C_01C51C02.68886A10" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.018 tagged_above=0 required=5 tests=AWL, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200502/327 X-Sequence-Number: 20437 This is a multi-part message in MIME format. ------=_NextPart_000_006C_01C51C02.68886A10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Did some searching on forums archives to no avail, I found a PL/Perl = example but would like to do this in plpgsql if possible. Does somebody = have this sitting around, I just dont want to reinvent the wheel. But = if need to I will. Thanks in advance, Oisin ------=_NextPart_000_006C_01C51C02.68886A10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Did some searching on forums archives = to no avail,=20 I found a  PL/Perl example but would like = to do=20 this in plpgsql if possible. Does somebody have this sitting around, I = just dont=20 want to reinvent the wheel.  But if need to I will.
 
Thanks in advance,
 
Oisin
------=_NextPart_000_006C_01C51C02.68886A10-- From ler@lerctr.org Sat Feb 26 19:05:46 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3EE8C5678F for ; Sat, 26 Feb 2005 19:05:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46127-05 for ; Sat, 26 Feb 2005 19:05:35 +0000 (GMT) Received: from lerami.lerctr.org (lerami.lerctr.org [192.147.25.11]) by svr1.postgresql.org (Postfix) with ESMTP id A0DA65677D for ; Sat, 26 Feb 2005 19:05:40 +0000 (GMT) Received: from lerlaptop.lerctr.org ([192.147.25.14]) by lerami.lerctr.org with esmtpsa (TLSv1:RC4-MD5:128) (Exim 4.50) id 1D57Fx-0000sF-Hu; Sat, 26 Feb 2005 13:05:38 -0600 From: Larry Rosenman To: "Oisin Glynn" Subject: Re: Reverse String in sql or pgplsql Date: Sat, 26 Feb 2005 13:05:39 -0600 User-Agent: KMail/1.7.1 Cc: pgsql-sql@postgresql.org References: <200502241717.14648.aarni@kymi.com> <1109424259.10941.6.camel@localhost.localdomain> <006f01c51c2c$54fb6ef0$a974fea9@homisco.local> In-Reply-To: <006f01c51c2c$54fb6ef0$a974fea9@homisco.local> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200502261305.40170.ler@lerctr.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/332 X-Sequence-Number: 20442 On Saturday 26 February 2005 11:55 am, Oisin Glynn wrote: > Did some searching on forums archives to no avail, I found a PL/Perl > example but would like to do this in plpgsql if possible. Does somebody > have this sitting around, I just dont want to reinvent the wheel. But if > need to I will. > > Thanks in advance, > > Oisin CREATE FUNCTION reverse(text) RETURNS text AS $_$ DECLARE original alias for $1; reverse_str text; i int4; BEGIN reverse_str := ''; FOR i IN REVERSE LENGTH(original)..1 LOOP reverse_str := reverse_str || substr(original,i,1); END LOOP; RETURN reverse_str; END;$_$ LANGUAGE plpgsql IMMUTABLE; from a posting a while back. From bmiller@nuvio.com Sat Feb 26 20:06:00 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9FB0D56499 for ; Sat, 26 Feb 2005 20:06:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66452-03 for ; Sat, 26 Feb 2005 20:05:48 +0000 (GMT) Received: from lothos.nuvio.com (unknown [63.77.68.101]) by svr1.postgresql.org (Postfix) with ESMTP id 566DB565B3 for ; Sat, 26 Feb 2005 20:05:53 +0000 (GMT) Received: from [63.77.68.30] ([63.77.68.30]) by lothos.nuvio.com with Microsoft SMTPSVC(5.0.2195.6713); Sat, 26 Feb 2005 14:08:22 -0600 In-Reply-To: <006f01c51c2c$54fb6ef0$a974fea9@homisco.local> References: <200502241717.14648.aarni@kymi.com> <1109424259.10941.6.camel@localhost.localdomain> <006f01c51c2c$54fb6ef0$a974fea9@homisco.local> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: multipart/alternative; boundary=Apple-Mail-49-144639714 Message-Id: <3177ec80719b1221976bd55c5a9bde44@nuvio.com> Cc: From: Bradley Miller Subject: Re: Reverse String in sql or pgplsql Date: Sat, 26 Feb 2005 14:05:42 -0600 To: "Oisin Glynn" X-Mailer: Apple Mail (2.619.2) X-OriginalArrivalTime: 26 Feb 2005 20:08:22.0406 (UTC) FILETIME=[EC11B260:01C51C3E] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.121 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/331 X-Sequence-Number: 20441 --Apple-Mail-49-144639714 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed create or replace function reverse_string(text) returns text as ' DECLARE reversed_string text; incoming alias for $1; BEGIN reversed_string =3D ''''; for i in reverse char_length(incoming)..1 loop reversed_string =3D reversed_string || substring(incoming from i for 1); end loop; return reversed_string; END' language plpgsql; select * from reverse_string('Postgres'); reverse_string sergtsoP On Feb 26, 2005, at 11:55 AM, Oisin Glynn wrote: > Did some searching on forums archives to no avail, I found a=A0=20 > PL/Perl=A0example but would like to do this in plpgsql if possible. = Does=20 > somebody have this sitting around, I just dont want to reinvent the=20 > wheel.=A0 But if need to I will. > =A0 > Thanks in advance, > =A0 > Oisin > Bradley Miller NUVIO CORPORATION Phone: 816-444-4422 ext. 6757 Fax: 913-498-1810 http://www.nuvio.com bmiller@nuvio.com --Apple-Mail-49-144639714 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 create or replace function reverse_string(text) returns text as=20 ' DECLARE=20 reversed_string text; incoming alias for $1; BEGIN reversed_string =3D ''''; for i in reverse char_length(incoming)..1 loop reversed_string =3D reversed_string || substring(incoming from i for 1); end loop; return reversed_string; END' language plpgsql; select * from reverse_string('Postgres'); reverse_string sergtsoP On Feb 26, 2005, at 11:55 AM, Oisin Glynn wrote: ArialDid some searching on forums archives to no avail, I found a=A0 PL/Perl=A0example but would like to do this in plpgsql if possible. Does somebody have this sitting around, I just dont want to reinvent the wheel.=A0 But if need to I will. =A0 ArialThanks in = advance, =A0 ArialOisin Bradley Miller = Arial1313,0000,FFFF= NUVIO = CORPORATIONA= rial Phone: 816-444-4422 ext. 6757 Fax: 913-498-1810 = 0000,0000,FFFFhttp://ww= w.nuvio.com = 0000,0000,FFFFbmiller@n= uvio.com --Apple-Mail-49-144639714--