On Sat, Apr 16, 2005 at 10:15:55AM +0300, Costin Manda wrote:
>
> In other SQL programs a division by zero is solved by transforming the
> result to NULL.
The SQL standards state that "If the value of a divisor is zero,
then an exception condition is raised: data exception -- division
by zero." Databases that silently convert this exception to NULL
(e.g., MySQL) are violating standards.
> How can I make postgres have the same behaviour without using CASE ?
Why don't you want to use CASE? Because it's unwieldy?
You could wrap CASE in a function and call that function instead
of using the / operator. I'd avoid any temptation to change the
behavior of the operator itself because that could cause problems
in other code that isn't expecting it.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/