8.1. Functions without a Simple Formula

Not all functions are computable via some simple formula. An obvious example is calendrical calculations that involve solar and lunar cycles, such as Easter. For a detailed discussion of the 14-step algorithm used by the Catholic Church to approximate Easter, I suggest reading The Calendar by David Ewing Duncan (ISBN-10: 1-85702-979-8).

But there are also functions that involve recursion, integrals, or other forms of higher math that are even harder to do with SQL’s rather simple set of functions. And even if you can write them, most SQL products do not correct for floating-point errors.

Lookup tables make the database code easier to maintain. The tricky functions are computed in an external tool or imported ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.