pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: keresztes_m@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: now() in loop statement
Date: Mon, 29 Sep 2003 15:14:39 METDST
Message-ID: <200309291314.PAA12563@rodos> (raw)
In-Reply-To: <bl9a9i$15g5$1@news.hub.org>

> 
> 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.
> 
Change 
mytime := now();
to 
mytime := ''now'';
and RTFM for details. 

Regards, Christoph 




view thread (4+ messages)  latest in thread

Message-ID: <200309291314.PAA12563@rodos>
Permalink:  ../200309291314.PAA12563@rodos/
Also on:    postgresql.org/message-id/200309291314.PAA12563@rodos

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, keresztes_m@yahoo.com
  Subject: Re: now() in loop statement
  In-Reply-To: <200309291314.PAA12563@rodos>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox