1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

How to use BASE36 conversion in Oracle / SQL?

Discussion in 'SQL - Questions and Answers' started by moneysa, Jun 13, 2006.

  1. moneysa New Member

    Dialect: Oracle
    I would like to know how to use BASE36 conversion in Oracle.
    Have a problem with number system (only 5 digits) running now out of numbers and would like to use alpha characters in the numbering system ie
    99999 next number A0000
    Thank You
  2. charlesryoung New Member

    Dialect: Oracle
    I assume you have a CHAR column in the database so you can hold the alpha characters. I don't know how to go to base 36 without a special function, but it is easy to go to hex. This would give you a maximum of 'fffff' which is decimal 1048575, over ten times the number of values you have now.

    SELECT TO_CHAR(1048575,'xxxxx') FROM dual

    TO_CHAR(1048575,'XXXXX')
    ------------------------
    fffff

    SELECT TO_NUMBER('fffff','xxxxx') FROM dual

    TO_NUMBER('FFFFF','XXXXX')
    ------------------------------
    1048575

Share This Page