[NOVICE] pl/pgsql and returns timestamp type - Mailing list pgsql-novice

From rmit.test2115@gmail.com
Subject [NOVICE] pl/pgsql and returns timestamp type
Date
Msg-id 3D7E1074.7C4B1520@technovell.com
Whole thread Raw
Responses Re: [NOVICE] pl/pgsql and returns timestamp type
List 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
whatis 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);

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org




pgsql-novice by date:

Previous
From: Terry Yapt
Date:
Subject: Re: pl/pgsql and returns timestamp type
Next
From: Roland Roberts
Date:
Subject: Unique indices and nulls