Cheque Package

Overview

This package contains functions which express a numeric amount of money in words, for use on a cheque.

The code is adapted from an example in Steven Feuerstein’s book Oracle PL/SQL Programming. I’ve improved the quality of the output and the efficiency of the procedure.

All the functions defined here have the necessary “purity level” to be used in SQL SELECT and WHERE clauses as well as PL/SQL.

Localisation

As written, this package returns amounts in pounds and pence expressed in English. To change the currency, simply change the values of the constants c_dollar, c_dollars, c_cent and c_cents to the singular and plural forms appropriate to your currency.

To change the language, you’re on your own! I’m unable to write a routine that works in all languages. Be aware, though, that the package relies in part on the TO_CHAR function to get its numbers, so changing the database NLS settings may have adverse affects on this package.

Function Definitions

int2words (number)
Expresses number (which must be an integer) in words.
amt2words (number)
Expresses number as an amount in pounds and pence.

Examples

cheque.int2words(1113)
Returns “One Thousand, One Hundred and Thirteen”
cheque.amt2words(123.45)
Returns “One Hundred and Twenty-three Pounds and Forty-Five pence”

Download

If the above has whetted your interest, you can download the package building script, cheque.zip (2,138 bytes). I hope you find it useful.

This code is made available for use in both private and commercial applications under a Creative Commons Licence.

Whilst every effort has been made to ensure these routines operate accurately and properly, no liability will be accepted for any problems they may cause on your system.

Leave a Comment