Function syntax ? - Mailing list pgsql-sql

From Ruben Gouveia
Subject Function syntax ?
Date
Msg-id 51e507b0809091055l2f83eb1dmf983c1e41da46c2a@mail.gmail.com
Whole thread Raw
Responses Re: Function syntax ?  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: Function syntax ?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-sql
<div dir="ltr">Does this syntax look correct? Can anyone think of a better way to write this?<br /><br />This function
willaccept two timestamp parameters and determine the highest of the two?<br /><br /><span style="color: rgb(204, 0,
0);">createor replace function fcn_max_dt(p_dt timestamp without time zone,</span><br style="color: rgb(204, 0, 0);"
/><spanstyle="color: rgb(204, 0, 0);">                                      p_dt2 timestamp without time
zone)</span><brstyle="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">returns timestamp without time
zoneas $$  </span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">  DECLARE</span><br
style="color:rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">      v_dt timestamp without time zone;</span><br
style="color:rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">      v_dt2 timestamp without time zone;</span><br
style="color:rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">   </span><br style="color: rgb(204, 0, 0);"
/><spanstyle="color: rgb(204, 0, 0);">  BEGIN</span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204,
0,0);">    v_dt := p_dt;</span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">    v_dt2 :=
p_dt2;</span><brstyle="color: rgb(204, 0, 0);" /><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0,
0);">   if v_dt >= v_dt2 then</span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">   
returnv_dt;</span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">    else</span><br
style="color:rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">    return v_dt2;</span><br style="color: rgb(204,
0,0);" /><span style="color: rgb(204, 0, 0);">    end if;</span><br style="color: rgb(204, 0, 0);" /><span
style="color:rgb(204, 0, 0);">        </span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0,
0);"> END;</span><br style="color: rgb(204, 0, 0);" /><span style="color: rgb(204, 0, 0);">$$ LANGUAGE
'plpgsql';</span><br/><br /><br /></div> 

pgsql-sql by date:

Previous
From: Lennin Caro
Date:
Subject: Re: PL/pgSQL function syntax question?
Next
From: "Scott Marlowe"
Date:
Subject: Re: Function syntax ?