Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f2UDEDK38288 for ; Fri, 30 Mar 2001 08:14:13 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from smtp-2.ig.com.br (smtp-2.ig.com.br [200.225.157.61] (may be forged)) by mail.postgresql.org (8.11.3/8.11.1) with SMTP id f2RI1qw59361 for ; Tue, 27 Mar 2001 13:01:52 -0500 (EST) (envelope-from edipoelder@ig.com.br) Message-Id: <200103271801.f2RI1qw59361@mail.postgresql.org> Received: (qmail 26026 invoked from network); 27 Mar 2001 18:01:46 -0000 Received: from webmail-9.ig.com.br (HELO localhost) (200.225.157.214) by smtp-2.ig.com.br with SMTP; 27 Mar 2001 18:01:46 -0000 Date: Tue, 27 Mar 2001 15:01:46 -0300 To: pgsql-sql@postgresql.org From: edipoelder@ig.com.br Cc: X-Originating-IP: [200.19.161.175] X-Mailer: InMail by Insite - www.insite.com.br X-user: edipoelder@ig.com.br Subject: Help with 'now', now(), timestamp 'now', ... X-Archive-Number: 200103/634 X-Sequence-Number: 2305 Hi all, I´m developing some procedures in my db and i want know how much time my procedures take to execute. So, i write my first procedure (to test) as follows: CREATE FUNCTION TEST(INTEGER) RETURNS INTEGER AS ' DECLARE SEQ RECORD; BEGIN SELECT NEXTVAL(''TIMES_ID_SEQ'') AS ID INTO SEQ; INSERT INTO TIMES (ID, START) VALUES (SEQ.ID, NOW()); FOR I IN 1..$1 LOOP ^^^^^ INSERT INTO TEST(ANUMBER) VALUES (RANDOM()*$1); END LOOP; UPDATE TIMES SET END = NOW() WHERE ID = SEQ.ID; RETURN SEQ.ID; ^^^^^ END;' LANGUAGE 'PLPGSQL'; and executed using "SELECT TEST(10000);". When it finish, i do a "SELECT * FROM TIMES" and got: test=> SELECT * FROM TIMES; start | end | id ----------+----------+---- 10:27:55 | 10:27:55 | 12 10:27:55 | 10:27:55 | 13 10:30:29 | 10:30:29 | 14 10:31:29 | 10:31:29 | 15 (4 rows) In id = 12 and id = 13, i runned two times. Then I changed the function and run, at id = 14. Change again at id = 15. Where is underlined (^^^^), i tried to put, 'now', timestamp 'now', etc, and always get the same time. What i'm doing wrong? obs.: -> TABLE TEST (ID SERIAL, ANUMBER INTEGER) -> TABLE TIMES (ID SERIAL, START TIME, END TIME); -> PostgreSQL 7.0.2 under Conectiva Linux Thanks, Edipo Elder [edipoelder@ig.com.br] _________________________________________________________ Oi! Você quer um iG-mail gratuito? Então clique aqui: http://www.ig.com.br/paginas/assineigmail.html