Em 12 de outubro de 2011 16:52, Marcelo Silva (IG) <[email protected]> escreveu: > Bem, depois da ajuda dos amigos aqui da lista, vendo que ainda não há algo > nativo no postgres, resolvi usar uma função para minhas pesquisas, assim > resolvo meu problema por hora. > > Segue a função caso alguém precise > > CREATE OR REPLACE FUNCTION fsemacento(character varying) > RETURNS character varying AS > $BODY$ > SELECT TRANSLATE(upper($1), > 'áéíóúàèìòùãõâêîôôäëïöüçÁÉÍÓÚÀÈÌÒÙÃÕÂÊÎÔÛÄËÏÖÜÇ', > 'aeiouaeiouaoaeiooaeioucAEIOUAEIOUAOAEIOOAEIOUC') > $BODY$ > LANGUAGE sql VOLATILE > COST 100; > ALTER FUNCTION fsemacento(character varying) OWNER TO postgres; > > Para usar faço o seguinte: (para buscar João, por exemplo) > > SELECT * FROM TABELA > WHERE (fsemacento(nome) = fsemacento('joao')) > > Pode-se usar com Like e afins > > > Além de ignorar os acentos ela também ignora maiusculas e minusculas > > > ps: Pessoal, não sou expert no PG, por isso caso haja alguma coisa a > melhorar nesta função, sou todo ouvidos! >
Você verificou a unaccent? http://www.postgresql.org/docs/current/interactive/unaccent.html e a citext? http://www.postgresql.org/docs/current/interactive/citext.html Osvaldo _______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
