X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 1782A310A48 for ; Tue, 1 Jul 2003 13:34:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 66114-08 for ; Tue, 1 Jul 2003 10:33:53 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 03F3C310A2C for ; Tue, 1 Jul 2003 10:33:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h61DXrQQ002455; Tue, 1 Jul 2003 09:33:53 -0400 (EDT) To: Erik Erkelens Cc: pgsql-sql@postgresql.org Subject: Re: CREATE SEQUENCE fails in plpgsql function In-reply-to: <20030630145012.88168.qmail@web41707.mail.yahoo.com> References: <20030630145012.88168.qmail@web41707.mail.yahoo.com> Comments: In-reply-to Erik Erkelens message dated "Mon, 30 Jun 2003 07:50:12 -0700" Date: Tue, 01 Jul 2003 09:33:53 -0400 Message-ID: <2454.1057066433@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200307/9 X-Sequence-Number: 14123 Erik Erkelens 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