From: | Pavel Křehula <pavel(dot)krehula(at)nlm(dot)cz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Creating a function |
Date: | 2018-11-28 10:00:17 |
Message-ID: | emd03fad66-0848-4689-a611-43ac8118d8a7@pavel6 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
something like this?
create or replace FUNCTION "IncentiveBin"(in Gwac double precision,
in MtgRaate double precision,
in BinSize double precision)
RETURNS double precision
LANGUAGE sql
VOLATILE PARALLEL SAFE
as 'select ceiling(($1 - $2)/$3) * $3;';
select "IncentiveBin"(1000.0,9,212);
Pavel
Dne 28.11.2018 10:35:09, "Glenn Schultz" <glenn(at)bondlab(dot)io> napsal:
>Hi,
>
>I am trying to create a function to bin based on user value and I am
>stuck. I followed the
>postgres create function tutoriall but I am missing something. Any
>help would be appreciated as I think I am just going further off course
>at this point
>
>Glenn
>
>CREATE FUNCTION "IncentiveBin"(in Gwac double precision,
> in MtgRaate double precision,
> in BinSize double precision)
> RETURNS double precision
> LANGUAGE 'sql'
> VOLATILE PARALLEL SAFE
>AS
>$function$
>BEGIN
>ceiling((Gwac - MtgRate)/BinSize) * BinSize;
>END
>$function$
From | Date | Subject | |
---|---|---|---|
Next Message | Durgamahesh Manne | 2018-11-28 10:28:31 | Regarding Tds_fdw |
Previous Message | Glenn Schultz | 2018-11-28 09:35:09 | Creating a function |