pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: edipoelder@ig.com.br
To: pgsql-sql@postgresql.org
Subject: Function with now() | time 'now' | etc...
Date: Wed, 28 Mar 2001 15:59:08 -0300
Message-ID: <200103281859.f2SIxDU52128@mail.postgresql.org> (raw)

Hi all, 

    I wrote the folling function: 

DROP FUNCTION PROC_TESTE(INTEGER); 
CREATE FUNCTION PROC_TESTE(INTEGER) RETURNS INTEGER AS ' 
DECLARE 
        SEQ RECORD; 
BEGIN 
        SELECT NEXTVAL(''TEMPOS_ID_SEQ'') AS ID INTO SEQ; 
        INSERT INTO TEMPOS (ID, INICIO) VALUES (SEQ.ID, NOW());              
           FOR I IN 1..$1 LOOP 
                INSERT INTO TESTE(VALOR) VALUES (RANDOM()*$1); 
        END LOOP; 
        UPDATE TEMPOS SET FIM = NOW() WHERE ID = SEQ.ID; 
        RETURN SEQ.ID; 
END;' 
LANGUAGE 'PLPGSQL'; 

    And all times I run it ("select proc_teste(10000);"), i got the folling 
behavour: 

teste=> SELECT * FROM TEMPOS; 
  inicio  |   fim    | id 
----------+----------+---- 
 15:12:17 | 15:12:17 | 23 
 15:12:18 | 15:12:18 | 24 
(...) 

    It doesn't getting different times on each execution. I also tried put 
"timestamp 'now'" insted "now()". What am I doing wrong? 

    Thank you, 

    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




view thread (3+ messages)  latest in thread

Message-ID: <200103281859.f2SIxDU52128@mail.postgresql.org>
Permalink:  ../200103281859.f2SIxDU52128@mail.postgresql.org/
Also on:    postgresql.org/message-id/200103281859.f2SIxDU52128@mail.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: edipoelder@ig.com.br
  Subject: Re: Function with now() | time 'now' | etc...
  In-Reply-To: <200103281859.f2SIxDU52128@mail.postgresql.org>
  References: <200103281859.f2SIxDU52128@mail.postgresql.org>

* 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