Operation precedence on postgress
- by user24691
I have set new division on postgress pg_operator table because i want tath when is division by zero return 0.
i have write this:
create operator / ( procedure = zero_division, leftarg = double precision, rightarg = double precision);
where zero_division is:
CREATE OR REPLACE FUNCTION zero_division(double precision, double precision)
RETURNS double precision AS
'select case when $2 = 0 then 0 else $1 / $2::real end;'
LANGUAGE sql IMMUTABLE
COST 100;
when i run value/ 0 i get error of division.