pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Larry Rosenman <ler@lerctr.org>
To: Oisin Glynn <me@oisinglynn.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Reverse String in sql or pgplsql
Date: Sat, 26 Feb 2005 13:05:39 -0600
Message-ID: <200502261305.40170.ler@lerctr.org> (raw)
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>

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.




view thread (3+ messages)  latest in thread

Message-ID: <200502261305.40170.ler@lerctr.org>
Permalink:  ../200502261305.40170.ler@lerctr.org/
Also on:    postgresql.org/message-id/200502261305.40170.ler@lerctr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ler@lerctr.org, me@oisinglynn.com
  Subject: Re: Reverse String in sql or pgplsql
  In-Reply-To: <200502261305.40170.ler@lerctr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox