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

Re: Error working with Temporary Sequences in plpgsql in 8.1 (8.0

From: Daniel Schuchardt <daniel_schuchardt(at)web(dot)de>
To: Jaime Casanova <systemguards(at)gmail(dot)com>
Subject: Re: Error working with Temporary Sequences in plpgsql in 8.1 (8.0
Date: 2006-02-03 19:25:48
Message-ID: 43E3AE3C.2020108@web.de (view raw or flat)
Thread:
Lists: pgsql-hackers
A nice workaraound because

EXECUTE 'select nextval(''test'')' INTO I;

 
doesnt work in 8.0 seems to be:

myid:=nextval('stvtrsid_seq'::TEXT);


This seems to work in every case.


Daniel


Jaime Casanova schrieb:

try this way:

CREATE OR REPLACE FUNCTION testseq() RETURNS void AS
$BODY$
 BEGIN
  EXECUTE 'CREATE TEMP SEQUENCE test';
  PERFORM testseq1();
  DROP SEQUENCE test;
  RETURN;
 END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION testseq() OWNER TO postgres;


CREATE OR REPLACE FUNCTION testseq1() RETURNS void AS
$BODY$
 DECLARE I INTEGER;
 BEGIN
  EXECUTE 'select nextval(''test'')' INTO I;
raise notice '%', I;
  RETURN;
 END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION testseq1() OWNER TO postgres;

SELECT testseq();
SELECT testseq();


is the same problem as with temp tables, you must put their creation,
and in this case even the nextval in an execute...

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2006-02-03 19:32:53
Subject: Re: Function Stats WAS: Passing arguments to views
Previous:From: Mark DilgerDate: 2006-02-03 19:19:29
Subject: Re: Function Stats WAS: Passing arguments to views

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