0

We have a Customer table with the "First name" and "Last name" columns. There are million of records in the table. Few of the records have French Accented charaters.

Example: Adélaïde, Amélie , etc.

I am looking for a DB2 function that can convert or translate accents into base ASCII characters.

Example:

Input: Amélie

Output: Amelia

I know we have a solution in Java. We can use Apache Commons StringUtils library to convert.

String input = StringUtils.stripAccents("Tĥïŝ ĩš â fůňķŷ Šťŕĭńġ");
System.out.println(input);

As of release 3.4, this does not work for Ø or Ł.

Below solution works and covers all the characters. translate(col,'aAeEiIoOuUaAeEuUaAeEiIoOuUeEiIoOuUcCnNaaaiAAAIoOyydDYooOOA','áÁéÉíÍóÓúÚàÀèÈùÙâÂêÊîÎôÔûÛëËïÏöÖüÜçÇñÑäãåìÄÃÅÌøØÿýðÐÝòõÒÕæ')

Note: æ is converted to A

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
Vinayak Dornala
  • 1,609
  • 1
  • 21
  • 27

2 Answers2

1

you can use the translate function if you want :

  translate(upper(ColName),'AAAEEEIIIOOOUUU','ÁÀÄÉÈËÍÌÏÓÒÖÚÙÜ')
Esperento57
  • 16,521
  • 3
  • 39
  • 45
  • using below command covers all the characters....translate(colname,'aAeEiIoOuUaAeEuUaAeEiIoOuUeEiIoOuUcCnNaaaiAAAIoOyydDYooOOA','áÁéÉíÍóÓúÚàÀèÈùÙâÂêÊîÎôÔûÛëËïÏöÖüÜçÇñÑäãåìÄÃÅÌøØÿýðÐÝòõÒÕæ') – Vinayak Dornala Oct 05 '16 at 19:14
0

https://www.senat.fr/questions/base/2018/qSEQ180303860.html

states the only characters authorized for french citizens names are

à-â-ä-é-è-ê-ë-ï-î-ô-ö-ù-û-ü-ÿ-ç and æ and œ so the answer would be

replace(replace((translate(lower(ColName),'aaaeeeeiioouuuyc','àâäéèêëïîôöùûüÿç')),'æ','ae'),'œ','oe')
frenchone
  • 1,547
  • 4
  • 19
  • 34