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--