Sometimes we may want to convert digits in English to Bengali or a Different Language.
We might use the following function to convert -
CREATE OR REPLACE FUNCTION F_Bdigits(input_value IN NUMBER)
RETURN VARCHAR2
IS
bengali_digits CONSTANT VARCHAR2(5000) := '০১২৩৪৫৬à§à§®à§¯'; -- Bengali digits in order
result VARCHAR2(4000);
input_string VARCHAR2(4000);
BEGIN
-- Handle NULL input gracefully
IF input_value IS NULL THEN
RETURN NULL;
END IF;
-- Format the number in Indian style with commas
input_string := TO_CHAR(input_value, 'FM99,99,99,99,990.00');
-- Replace each digit (0-9) with its Bengali equivalent
result := input_string;
FOR i IN 0..9 LOOP
result := REPLACE(result, TO_CHAR(i), SUBSTR(bengali_digits, i + 1, 1));
END LOOP;
RETURN result;
EXCEPTION
WHEN OTHERS THEN
RETURN 'Error in conversion'; -- Graceful error handling
END;
/
Check in sqlplus :
SELECT F_bdigits(1234567890) FROM DUAL;