postgresql - Using extract function in your own sql function -


i'm trying create following function postgres database:

create or replace function public.extract_hour(time_param timestamp time zone) returns double precision language sql $function$ select extract(hour timestamp time_param); $function$; 

but following error:

error:  syntax error @ or near "time_param" 

i tried put instead of time_param $0, same error occur. can explain me how solve that?

obviously, using older version of postgresql (which neglected provide). referring parameter names possible since postgresql 9.2. in older versions can refer positional parameters:

create or replace function public.extract_hour(time_param timestamptz)   returns double precision language sql $function$ select extract(hour $1); $function$;

also removed misplaced keyword timestamp.

while referring parameter names has been possible in pl/pgsql functions long time now.
we fixed documentation glitch opposite recently.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -