Unix Technical Forum

EXECUTE plpgsql

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 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 08:05 AM
Julio Leyva
 
Posts: n/a
Default EXECUTE plpgsql

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 08:05 AM
Tom Lane
 
Posts: n/a
Default Re: EXECUTE plpgsql

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:16 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com