CREATE OR REPLACE FUNCTION number_to_core_lac(p_number IN NUMBER) RETURN VARCHAR2 IS
l_crores NUMBER := TRUNC(p_number / 10000000);
l_lacs NUMBER := TRUNC(MOD(p_number, 10000000) / 100000);
BEGIN
RETURN CASE
WHEN l_crores > 0 AND l_lacs > 0 THEN l_crores || ' Core, ' || l_lacs || ' Lac'
WHEN l_crores > 0 THEN l_crores || ' Core'
WHEN l_lacs > 0 THEN l_lacs || ' Lac'
ELSE '0 Lac'
END;
END;
/
SELECT number_to_core_lac(99994050000) AS "55 Core, 44 Lac" FROM DUAL;
No comments:
Post a Comment