Klatten
Klatten

Reputation: 312

Replacing multiple characters with Oracle

I need to replace several characters in a text string from my database. I have a database containing people's names, but as I am from a country where we use "illegal" characters, such as "Æ", "Ø" and "Å", I have to filter these out and replace them with other characters – and each of the "illegal characters" will have their own "legal character" they will be switched to. For example "å" will become "a", "æ" will become "e" and so on.

I have tried doing it like this:

select TRANSLATE(FIRSTNAME || '.' || LASTNAME, 'å', 'a')
from mytable

This will do the trick when a person's name contains 'å', but how can I do this for several characters at the same time?

Upvotes: 0

Views: 106

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269753

You just list the characters in the translation strings:

select TRANSLATE(FIRSTNAME || '.' || LASTNAME, 'åaeiou', 'a12345')
from mytable

Upvotes: 2

Related Questions