Re: PGsql function timestamp issue

Поиск
Список
Период
Сортировка
От bricklen
Тема Re: PGsql function timestamp issue
Дата
Msg-id CAGrpgQ9U86N0xQYYx7bV3Ct_z_ehDBuz5D8H4a_Kmy1gMOiq5w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PGsql function timestamp issue  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-sql
<div dir="ltr"><div class="gmail_extra"><br /><div class="gmail_quote">On Thu, May 29, 2014 at 2:13 PM, Steve Crawford
<spandir="ltr"><<a href="mailto:scrawford@pinpointresearch.com"
target="_blank">scrawford@pinpointresearch.com</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="margin:00 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/29/2014 01:46 PM, ng wrote:<br /><blockquote
class="gmail_quote"style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br /> create or replace
functiondw.fx_nish()<br /> returns text<br />   language plpgsql<br />   as<br /> $$<br /> declare<br /> x timestamp
withtime zone;<br /> y timestamp with time zone;<br /> begin<br /> x:= current_timestamp;<br /> perform pg_sleep(5);<br
/>y:= current_timestamp;<br /> if x=y then<br /> return 'SAME';<br /> else<br /> return 'DIFFERENT';<br /> end if;<br
/><br/> end;<br /> $$<br /><br /><br /> select dw.fx_nish()<br /> This give me 'SAME'<br /><br /> Any work around for
this?<br/></blockquote><br /> No and yes.<br /><br /> The value of current_timestamp will remain constant throughout a
transactionso the function is returning the expected result.<br /><br /> You can use timeofday() but since that returns
astring representing wall-clock time and does increment within a transaction. To get a timestamptz you will need to
castit: timeofday()::timestamptz<br /></blockquote></div><br /></div><div class="gmail_extra">Or use
clock_timestamp()<br/></div></div> 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Steve Crawford
Дата:
Сообщение: Re: PGsql function timestamp issue
Следующее
От: David G Johnston
Дата:
Сообщение: Re: Parameterized Query