Re: Reverse String in sql or pgplsql - Mailing list pgsql-sql

From Larry Rosenman
Subject Re: Reverse String in sql or pgplsql
Date
Msg-id 200502261305.40170.ler@lerctr.org
Whole thread Raw
In response to Reverse String in sql or pgplsql  ("Oisin Glynn" <me@oisinglynn.com>)
List pgsql-sql
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.



pgsql-sql by date:

Previous
From: Bradley Miller
Date:
Subject: Re: Reverse String in sql or pgplsql
Next
From: Michael Fuhr
Date:
Subject: Re: AutoCommit and DDL