Saturday, October 2, 2010

How to use TRANSLATE function?

TO ENCODE TEXT

SELECT TRANSLATE (UPPER('Hello world'),
                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                  '~!@#$%^*()_+=-`/;:><[]{}\|') AS CODE
  FROM DUAL;

TO DECODE TEXT

SELECT TRANSLATE ('*( -(+~\ *`{ ~:$ \`[?',
                  '~!@#$%^*()_+=-`/;:><[]{}\|',
                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ') AS TEXT
  FROM DUAL;

No comments:

Post a Comment