Re: how to ignore accents?

From: Ennio-Sr <nasr(dot)laili(at)tin(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to ignore accents?
Date: 2005-03-31 18:38:02
Message-ID: 20050331183802.GA3060@deby.ei.hnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

* Michael Fuhr <mike(at)fuhr(dot)org> [300305, 17:42]:
> On Thu, Mar 31, 2005 at 02:01:45AM +0200, Ennio-Sr wrote:
> >
> > I'm not an expert, but I'm afraid it's not possible to do that (and I'd
> > be glad if somebody came out saying I'm wrong as I've the same problem).
>
> You could write an unaccent() function that calls translate().
>
> http://www.postgresql.org/docs/8.0/interactive/functions-string.html
>
> Here's an (incomplete) example that works in PostgreSQL 8.0.2beta1:
>
> CREATE FUNCTION unaccent(text) RETURNS text AS $$
> BEGIN
> RETURN translate($1, '\342\347\350\351\352\364\373', 'aceeeou');
> END;
> $$ LANGUAGE plpgsql IMMUTABLE STRICT;
>

Thank you, Michael, for correcting my pessimism (and ignorance ... :-).
Is there any chance to have that work with PostgreSQL-7.4.7-2 (the
latest available from Debian/sarge)?
I put those instructions in a .sql file, did:
mydb=> \i unaccent.sql
and got:
psql:unaccent.sql:3: ERROR: syntax error at or near "$" at character 50
psql:unaccent.sql:4: WARNING: there is no transaction in progress
COMMIT
psql:unaccent.sql:5: ERROR: syntax error at or near "$" at character 3

Regards,
Ennio.

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?//
Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that. )=(
Do something you aren't good at!" (as Henry Miller used to say) ]

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-03-31 19:24:52 Re: how to ignore accents?
Previous Message Chris Jensen 2005-03-31 17:31:36 Re: rpm install issues - RHE3