Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5593B476689 for ; Tue, 26 Nov 2002 08:58:09 -0500 (EST) Received: from cmnt4011.rvc.ac.uk (cmnt4011.rvc.ac.uk [195.195.217.13]) by postgresql.org (Postfix) with ESMTP id 3C685476463 for ; Tue, 26 Nov 2002 08:54:25 -0500 (EST) Received: by cmnt4011.rvc.ac.uk with Internet Mail Service (5.5.2653.19) id ; Tue, 26 Nov 2002 13:54:10 -0000 Message-ID: <6BD8CE460CC6EE40B83DDFCED609F84BE140D9@cmnt4008.rvc.ac.uk> From: "Rison, Stuart" To: "'pgsql-sql@postgresql.org'" Subject: Two TIMESTAMPs in one pl/sql function Date: Tue, 26 Nov 2002 13:54:20 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/368 X-Sequence-Number: 10510 Hi, I'm trying to time a pl/sql function using a rougn and ready method, basically: print a TIMESTAMP at the begining of the function, print a TIMESTAMP at the end of the function. So...: CREATE OR REPLACE FUNCTION timer() RETURNS INTEGER AS ' DECLARE timer1 TIMESTAMP; timer2 TIMESTAMP; num_operators INTEGER; BEGIN timer1 := ''now''; -- As suggested in 23.4 of programmer guide RAISE NOTICE ''Start: %'', timer1; /* Some function which takes time. Here, a select from a pg catalogue */ SELECT INTO num_operators COUNT(*) FROM pg_operator; timer2 := ''now''; RAISE NOTICE ''End: %'', timer2; RETURN(num_operators); END;' LANGUAGE 'plpgsql'; Gives me: testdb2=# select timer(); NOTICE: Start: 2002-11-26 13:40:14.116605+00 NOTICE: End: 2002-11-26 13:40:14.116605+00 timer ------- 623 (1 row) I've tried all sorts of variations but I hit one of two problems; either the TIMESTAMP is fixed to the function compile time or, as above, the timer1 and timer2 TIMESTAMPs are always identical. Any help/pointers/suggestions appreciate... well of course a working solution would be the best ;) Cheers, Stuart.