CREATE OR REPLACE FUNCTION to_words (
m_amount_in IN NUMBER
m_first_para IN VARCHAR
m_second_para IN VARCHAR
)
RETURN VARCHAR
AS
m_amount NUMBER := m_amount_in;
word_string VARCHAR
lower_number NUMBER;
lower_str VARCHAR
loop_var NUMBER :=
/* Function declarartion to convert into string */
FUNCTION to_string (m_val_in NUMBER)
RETURN CHAR
IS
BEGIN
IF m_val_in >
THEN
RETURN (INITCAP (TO_CHAR (TO_DATE (m_val_in
ELSE
RETURN (
END IF;
END;
/* End of Function */
BEGIN
/*
lower_number := (m_amount MOD
/* Check for lower denominations not exceeding two digits */
IF length(lower_number) <
THEN
IF m_amount >=
THEN lower_str :=
m_first_para ||
LOWER (to_string (lower_number)) ||
m_second_para;
ELSIF m_amount <
THEN lower_str :=
LOWER (to_string (lower_number)) ||
m_second_para;
ELSIF m_amount >=
THEN lower_str :=
END IF;
ELSE
word_string :=
RETURN (word_string);
END IF;
/*
WHILE loop_var =
LOOP
IF m_amount >
AND m_amount <=
THEN
word_string :=
word_string ||
(INITCAP (to_string (FLOOR (m_amount))) || lower_str);
loop_var :=
ELSIF m_amount >
AND m_amount <
THEN
word_string :=
word_string ||
(INITCAP (to_string (FLOOR (m_amount /
to_string (FLOOR (m_amount MOD
lower_str
);
loop_var :=
ELSIF m_amount >=
AND m_amount <
THEN
word_string :=
word_string ||
INITCAP (to_string (FLOOR (m_amount /
m_amount := FLOOR (m_amount MOD
IF m_amount =
THEN
loop_var :=
word_string := word_string || lower_str;
END IF;
ELSIF m_amount >=
AND m_amount <=
THEN
word_string :=
INITCAP (
to_string (FLOOR (m_amount /
m_amount := FLOOR (m_amount MOD
IF m_amount =
THEN
loop_var :=
word_string := word_string || lower_str;
END IF;
ELSIF m_amount =
THEN
word_string := (
loop_var :=
ELSE
word_string :=
loop_var :=
END IF;
END LOOP;
RETURN (word_string);
END to_words;
/
From:http://tw.wingwit.com/Article/program/Oracle/201311/17291.html