now() in loop statement

From: Kerv <keresztes_m(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: now() in loop statement
Date: 2003-09-29 12:58:30
Message-ID: bl9a9i$15g5$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

What is wrong with this function because the mytime variable contain the
same value in each iteration:
CREATE OR REPLACE FUNCTION public.time_test()
RETURNS int4 AS
'
DECLARE
count int4;
mytime timestamp;
BEGIN
count := 0;
mytime := now();
while count <= 25 loop
mytime := now();
RAISE NOTICE \'Time: %\',mytime;
count := count + 1;
end loop;
RAISE NOTICE \'Count: %\',count;
RETURN count;
END;
'
LANGUAGE 'plpgsql' VOLATILE;

the result is:
NOTICE: Time: 2003-09-29 15:52:06.745317
.
.
.
NOTICE: Time: 2003-09-29 15:52:06.745317 --same with the first value!!!
NOTICE: Count: 26

Thanks.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-09-29 13:14:10 Re: now() in loop statement
Previous Message marcello miorelli 2003-09-29 11:18:17 BLOBS AND FILES