--============================================================================ -- Copywright 2002, joel crainshaw & chet west --============================================================================ -- DESCRIPTION -- convert a number to words for printinng checks -- there are numerous solutions and this one was pulled together -- from several other solutions we found; unfortunately, we don't have -- the original author out function is baased on to provide credit -- -- this is the "limited" solution that usses julian date conversions -- to simply accomplish the results whichh limits our output to -- $5,373,484.00 --============================================================================ -- MODIFICATION HISTORY -- Person Date Comments -- --------- ---------- -------------------------------------------- -- chet/joel ??/??/2001 Initial Creation --============================================================================ CREATE OR REPLACE FUNCTION currencywords ( p_val IN NUMBER ) RETURN CHAR IS cents NUMBER; c_str VARCHAR2 (80); FUNCTION spell ( p_value IN NUMBER ) RETURN CHAR IS BEGIN IF p_value > 0 THEN RETURN (INITCAP (TO_CHAR (TO_DATE (p_value, 'j'), 'jsp'))); ELSE RETURN (''); END IF; END spell; -- BEGIN cents := MOD (p_val, 1) * 100; IF cents > 0 THEN -- creates string for cents c_str := ' dollars AND ' || LOWER (spell (cents)) || ' cents'; ELSE c_str := ' dollars AND zero cents'; END IF; IF p_val >= 1 AND p_val <= 5373484 THEN -- creates dollar string up to $5,373,484.00 RETURN ('** the SUM OF '|| INITCAP (spell (FLOOR (p_val))) || c_str || '**'); ELSE RETURN ('** error **'); END IF; END; -- Function CURRENCYWORDS