This is a discussion on EXECUTE plpgsql within the pgsql Admins forums, part of the PostgreSQL category; --> Hi allI'm trying to get the next value from a sequence using a store procedure like thiscreate or replace ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi allI'm trying to get the next value from a sequence using a store procedure like thiscreate or replace function givemenext() returns integer AS $$DECLAREnewvalue integer;getseq varchar(256);BEGINreturn EXECUTE 'SELECT nextval(''test_id_seq'')';END;$$ language plpgsqlSo when I do select * from givemenext()I got this error messageERROR: type "execute" does not existCONTEXT: SQL statement "SELECT EXECUTE 'SELECT nextval(''test_id_seq'')'"PL/pgSQL function "givemenext" line 11 at returnWhat I'm doing wrong?Thanks in advance |
| ||||
| Julio Leyva <jcleyva@hotmail.com> writes: > Hi allI'm trying to get the next value from a sequence using a store proced= > ure like thiscreate or replace function givemenext() returns integer AS $$= > DECLAREnewvalue integer;getseq varchar(256);BEGINreturn EXECUTE 'SELECT nex= > tval(''test_id_seq'')';END;$$ language plpgsqlSo when I do select * from gi= > vemenext()I got this error messageERROR: type "execute" does not existCONT= > EXT: SQL statement "SELECT EXECUTE 'SELECT nextval(''test_id_seq'')'"PL/p= > gSQL function "givemenext" line 11 at returnWhat I'm doing wrong?Thanks in = > advance= Please try to use a less broken mailer :-( Anyway, that seems like the hard way. Why not just return nextval('test_id_seq'); regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |