Skip site navigation (1) Skip section navigation (2)

pl/pgsql and returns timestamp type

From: Terry Yapt <yapt(at)technovell(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: pl/pgsql and returns timestamp type
Date: 2002-09-10 15:32:04
Message-ID: 3D7E1074.7C4B1520@technovell.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi all,

I cannot to get this to run...  I think I am mistaking some basic concept or I have a big brain-lock .  Somebody know what is the problem to execute this function ?

Thanks in advance...

--====================================
DROP TABLE test;
CREATE TABLE test
(
  clave numeric(7,0) not null,
  PRIMARY KEY (clave)
) WITHOUT OIDS;
--====================================
DROP FUNCTION f_test(numeric(7,0), numeric(7,0));
CREATE OR REPLACE FUNCTION f_test(numeric(7,0), numeric(7,0)) RETURNS timestamp AS '
  DECLARE
    p_datod ALIAS FOR $1;
    p_datoh ALIAS FOR $2;
    --
    tdesde timestamp;
    thasta timestamp;
  BEGIN
    tdesde := now();
    --
    FOR X IN p_datod..p_datoh LOOP
      INSERT INTO test VALUES (x);    
    END LOOP;
    --
    thasta := now() - tdesde;
    RETURN thasta;
  COMMIT;
  END;
' LANGUAGE 'plpgsql';
--====================================
select f_test(1,9);

Responses

pgsql-novice by date

Next:From: Josh BerkusDate: 2002-09-10 15:34:23
Subject: Re: Problems with substring
Previous:From: Ernesto JardimDate: 2002-09-10 14:31:03
Subject: login problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group