X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A44C7D1B548 for ; Mon, 29 Sep 2003 13:15:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86208-01 for ; Mon, 29 Sep 2003 10:14:45 -0300 (ADT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 892D2D1B530 for ; Mon, 29 Sep 2003 10:14:40 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon Sep 29 15:14:40 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id PAA29689; Mon, 29 Sep 2003 15:14:40 +0200 (METDST) From: Christoph Haller Message-Id: <200309291314.PAA12563@rodos> Subject: Re: now() in loop statement To: keresztes_m@yahoo.com (Kerv) Date: Mon, 29 Sep 2003 15:14:39 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: ; from "Kerv" at Sep 29, 103 3:04 pm X-Mailer: Elm [revision: 212.4] X-Virus-Scanned: by amavisd-new at postgresql.org X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char 9C hex) in message header 'Received' Received: \234by rodos.fzk.de... ^ X-Archive-Number: 200309/381 X-Sequence-Number: 15359 > > 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