using a function in where - Mailing list pgsql-general

From Glenn Schultz
Subject using a function in where
Date
Msg-id CAE-4=KG7ZYpTntiLZfL8AN+3oE2OmxDRDUaoWpeGz+cFxBy9mA@mail.gmail.com
Whole thread Raw
Responses Re: using a function in where  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Re: using a function in where  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
All,
I am using the function below to convert a continuous variable to a binned value.  Sometimes a value other than zero is passed through the query. For example -.5 result value is passed to the query result.  The basic of the query is below.  

select
incentivebin(wac, rate, .25)
from
my_table
where incentivebin(was, rate, .25) = 0

I have checked the function works correctly and the raw values match those values expected from simple subtraction and are in the correct bin.  I am not sure why some values would be allowed through the query. Any ideas would be appreciated.

Best,
Glenn


CREATE or REPLACE FUNCTION embs_owner.IncentiveBin(IN "Gwac" double precision, 
  IN "MtgRate" double precision, 
  IN "BinSize" double precision)
    RETURNS double precision
    LANGUAGE 'sql'
    PARALLEL SAFE
AS 'select ceiling(($1 - $2)/$3) *$3';

ALTER FUNCTION embs_owner.IncentiveBin(double precision, double precision, double precision)
    OWNER TO embs_owner;

pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: psql is hanging
Next
From: Andrew Gierth
Date:
Subject: Re: using a function in where