Apparently there is a hack for integers using conversion to julian date: HOW TO: Spell a number or convert a number to words
SELECT TO_CHAR (TO_DATE (1234567, 'j'), 'jsp') FROM DUAL;
You can split SALARY
into integer dollars and cents and apply the hack:
Select
TO_CHAR (TO_DATE (Dollars, 'j'), 'jsp') || ' dollars ' ||
TO_CHAR (TO_DATE (Cents, 'j'), 'jsp') || ' cents' As Spelling
From (
Select
TRUNC(1254.20) As Dollars,
(1254.20 - TRUNC(1254.20)) * 100 As Cents
From DUAL);
Admittedly you also need to cover for single dollar / cent.
Best be done in a function.
CREATE OR REPLACE FUNCTION spell_amount
(srcAmnt IN NUMBER)
RETURN VARCHAR2
IS
Dollars INT;
Cents INT;
Result VARCHAR2(1000);
BEGIN
Dollars := Trunc(srcAmnt);
Cents := Trunc((srcAmnt - Dollars)*100);
IF Dollars = 0 THEN
Result := 'no dollars';
ELSIF Dollars = 1 THEN
Result := 'one dollar';
ELSE
Result := TO_CHAR (TO_DATE (Dollars, 'j'), 'jsp') || ' dollars';
END IF;
IF Cents = 0 THEN
Result := Result || ' no cents';
ELSIF Cents = 1 THEN
Result := Result || ' one cent';
ELSE
Result := Result || ' ' || TO_CHAR (TO_DATE (Cents, 'j'), 'jsp') || ' cents';
END IF;
RETURN Result;
END spell_amount;
/
And then
Select spell_amount(132.01) From DUAL;
Some more on ORA-01854: julian date must be between 1 and 5373484
limitation of Julian date and possible solution: How To Convert Number into Words using Oracle SQL Query
And SQL Fiddle