How to Save Hindi Numbers in Your Database

A while back, I received a requirement to save Hindi numbers in our database.

It took some research and here’s how I solved it:

If your character-set is UTF8 then you can save Hindi numbers in varchar2 column type.

If your character-set is AR8MSWIN1256 or AR8ISO8859P6, then you can’t save Hindi numbers in varchar2 columns. You only can save them in nvarchar columns. In this case your national character-set (UTF16 or UTF8) would come in play.

Most likely you won’t be able to type Hindi numbers in SQLPlus, Toad, etc…, instead you can use unistr function to insert and query back the data.

Here is quick example to demonstrate how to insert and select numbers 123:

Insert into hindi_table (col1) values (unistr (‘\0661\0662\0663’));

Select col1 from hindi_table where col1 = unistr (‘\0661\0662\0663’);

Remember either varchar2/UTF8 character-set or nvarchar2/(UTF16 or UTF8) national character-set

Hazem Ameen
Senior Oracle DBA

Advertisements

6 thoughts on “How to Save Hindi Numbers in Your Database

  1. hi
    thank you for your comments
    but i changed the character set from AL16UTF16 to be UTF8 but it doesn’t allow this because the UTF8 must a super set of AL16UTF16
    So, according to this error, i think that AL16UTF16 must save hibdi numbers
    please advice

  2. thank u for your reply
    i think the problem was from my encoding since i added the data containing the hindi numbers using
    windows-1256 and it add its encoding
    i think this encoding doesn’t support these numbers

    1. Dear Hazem,

      i have tried your solution for storing and retrieving the hindi numbers but i failed all came up with question marks.can you tell me how to fix it and what character-set should i use to support the HINDI numbers. this is my lang and character-set:-

      select * from NLS_DATABASE_PARAMETERS;

      PARAMETER VALUE

      NLS_LANGUAGE AMERICAN
      NLS_TERRITORY AMERICA
      NLS_CURRENCY $
      NLS_ISO_CURRENCY AMERICA
      NLS_NUMERIC_CHARACTERS .,
      NLS_CHARACTERSET AR8MSWIN1256
      NLS_CALENDAR GREGORIAN
      NLS_DATE_FORMAT DD-MON-RR
      NLS_DATE_LANGUAGE AMERICAN
      NLS_SORT BINARY
      NLS_TIME_FORMAT HH.MI.SSXFF AM
      NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
      NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
      NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
      NLS_DUAL_CURRENCY $
      NLS_COMP BINARY
      NLS_LENGTH_SEMANTICS BYTE
      NLS_NCHAR_CONV_EXCP FALSE
      NLS_NCHAR_CHARACTERSET AL16UTF16
      NLS_RDBMS_VERSION 10.2.0.1.0

      thank you in advance

      1. hello…. same problem…. do you get any solution, how to get out of the question mark???
        i am using asp.net and oracle 10g express edition.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s