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