Skip to content

Instantly share code, notes, and snippets.

@samirfor
Last active November 19, 2018 19:01
Show Gist options
  • Save samirfor/ef7c45401ddd53baa8df783bc0b4925b to your computer and use it in GitHub Desktop.
Save samirfor/ef7c45401ddd53baa8df783bc0b4925b to your computer and use it in GitHub Desktop.
Uma funçãozinha para remover acentos de strings no PostgreSQL... Útil.
-- Uma funçãozinha para remover acentos de strings no PostgreSQL... Útil.
-- Créditos: papo sql
CREATE OR REPLACE FUNCTION retira_acentuacao(p_texto text) RETURNS text AS $BODY$
SELECT TRANSLATE($1,
'áàâãäåÁÀÂÃÄÅéèêẽëÉÈÊẼËíìîïÍÌÎÏóòôõöÓÒÔÕÖúùûüÚÙÛŨÜçÇñÑýÝ',
'aaaaaaAAAAAAeeeeeEEEEEiiiiIIIIoooooOOOOOuuuuUUUUUcCnNyY'
);
$BODY$ LANGUAGE SQL VOLATILE COST 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment