Excerpts from Osvaldo Mendoza's message of mar ago 10 12:46:06 -0400 2010:
>
> Buenas, necesito haber si existe una funcion para inversion de caracteres de
> un campo.
>
> Ejemplo:
> Juan Costa --> atsoC nauJ
CREATE OR REPLACE FUNCTION reverse(TEXT) RETURNS TEXT AS $$
SELECT
array_to_string(
ARRAY
( SELECT substring($1, s.i,1) FROM generate_series(length($1), 1, -1)
AS s(i) ),
'');
$$ LANGUAGE SQL IMMUTABLE;
Tomada de aquí:
http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks#LIKE_optimalization
alvherre=# select reverse('Juan Costa');
reverse
------------
atsoC nauJ
(1 fila)
--
Álvaro Herrera <[email protected]>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
-
Enviado a la lista de correo pgsql-es-ayuda ([email protected])
Para cambiar tu suscripci�n:
http://www.postgresql.org/mailpref/pgsql-es-ayuda