From: | edipoelder(at)ig(dot)com(dot)br |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Help with 'now', now(), timestamp 'now', ... |
Date: | 2001-03-27 18:01:46 |
Message-ID: | 200103271801.f2RI1qw59361@mail.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all,
Im 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(at)ig(dot)com(dot)br]
_________________________________________________________
Oi! Voc quer um iG-mail gratuito?
Ento clique aqui: http://www.ig.com.br/paginas/assineigmail.html
From | Date | Subject | |
---|---|---|---|
Next Message | Gerald Gutierrez | 2001-03-27 18:57:35 | RE: AY<g*:'t8q |
Previous Message | tjk@tksoft.com | 2001-03-27 17:10:03 | Re: Re: Still don't know how to build this string ? how to concat ?? |