From: Tom Lane <tgl@sss.pgh.pa.us>
To: Julio Leyva <jcleyva@hotmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: EXECUTE plpgsql
Date: Sat, 11 Aug 2007 12:04:58 -0400
Message-ID: <2233.1186848298@sss.pgh.pa.us> (raw)
In-Reply-To: <BAY120-W44E61B77A185D9588610CA1E20@phx.gbl>
References: <BAY120-W44E61B77A185D9588610CA1E20@phx.gbl>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, jcleyva@hotmail.com
Subject: Re: EXECUTE plpgsql
In-Reply-To: <2233.1186848298@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox