From: Tom Lane <tgl@sss.pgh.pa.us>
To: Erik Erkelens <erik_erkelens@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: CREATE SEQUENCE fails in plpgsql function
Date: Tue, 01 Jul 2003 09:33:53 -0400
Message-ID: <2454.1057066433@sss.pgh.pa.us> (raw)
In-Reply-To: <20030630145012.88168.qmail@web41707.mail.yahoo.com>
References: <20030630145012.88168.qmail@web41707.mail.yahoo.com>
Erik Erkelens <erik_erkelens@yahoo.com> writes:
> DECLARE
> new_max_records ALIAS FOR $1;
> BEGIN
> CREATE SEQUENCE my_sequence MAXVALUE new_max_records CYCLE;
> ERROR: parser: parse error at or near "$1" at character 39
You'll need to use EXECUTE to construct and execute that CREATE
SEQUENCE. Utility statements generally don't accept runtime parameters,
which is what the plpgsql variable looks like to the main parser.
> Also, if there is a better mechanism to implement
> this, I'm all ears...
There's an ALTER SEQUENCE command in CVS tip, though I'm not sure
I trust it in concurrent-usage scenarios :-(
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, erik_erkelens@yahoo.com
Subject: Re: CREATE SEQUENCE fails in plpgsql function
In-Reply-To: <2454.1057066433@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