RE: Help with 'now', now(), timestamp 'now', ...

From: "Trewern, Ben" <Ben(dot)Trewern(at)mowlem(dot)com>
To: "'edipoelder(at)ig(dot)com(dot)br'" <edipoelder(at)ig(dot)com(dot)br>, pgsql-sql(at)postgresql(dot)org
Subject: RE: Help with 'now', now(), timestamp 'now', ...
Date: 2001-03-30 14:49:46
Message-ID: 996802F75C3CD411B424001083FA445B059562@CET_PONXX_FP001
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

try timeofday(), now() gives starttime of transaction :-{.

Regards

Ben

PS this has just been discussed in this mailing list or I would have been
clueless

> -----Original Message-----
> From: edipoelder(at)ig(dot)com(dot)br [mailto:edipoelder(at)ig(dot)com(dot)br]
> Sent: 27 March 2001 19:02
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] Help with 'now', now(), timestamp 'now', ...
>
>
> 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(at)ig(dot)com(dot)br]
>
> _________________________________________________________
> Oi! Você quer um iG-mail gratuito?
> Então clique aqui: http://www.ig.com.br/paginas/assineigmail.html
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

*****************************************************************************
This email and any attachments transmitted with it are confidential
and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the sender and do not store, copy or disclose the content
to any other person.

It is the responsibility of the recipient to ensure that opening this
message and/or any of its attachments will not adversely affect
its systems. No responsibility is accepted by the Company.
*****************************************************************************

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2001-03-30 15:09:27 Re: 'Include' function in SQL scripts
Previous Message Trewern, Ben 2001-03-30 14:42:29 RE: Max Size of a text field