Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A23E063250C for ; Fri, 23 Jul 2010 20:32:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 21378-02 for ; Fri, 23 Jul 2010 23:32:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.speedypuppy.net (mailserve1.speedypuppy.net [72.44.78.8]) by mail.postgresql.org (Postfix) with ESMTP id 11AD662E706 for ; Fri, 23 Jul 2010 20:32:19 -0300 (ADT) Received: (qmail 26440 invoked by uid 399); 23 Jul 2010 23:37:00 -0000 Received: from unknown (HELO ?10.0.1.196?) (frankel@circlesfx.com@71.139.178.21) (de-)crypted with TLSv1: AES128-SHA [128/128] DN=unknown by mail.speedypuppy.net with ESMTPSAM; 23 Jul 2010 23:37:00 -0000 X-Originating-IP: 71.139.178.21 X-Sender: frankel@circlesfx.com Cc: "PostgreSQL List" Message-Id: <022BE477-69E6-41FD-9455-C1A7756B19F0@circlesfx.com> From: Scott Frankel To: Daniel Verite In-Reply-To: <25ac0333-7cf9-4410-9c43-fba7815bb918@mm> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: prepared statements Date: Fri, 23 Jul 2010 16:32:17 -0700 References: <25ac0333-7cf9-4410-9c43-fba7815bb918@mm> X-Mailer: Apple Mail (2.936) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.5 tagged_above=-5 required=5 tests=BAYES_05=-0.5 X-Spam-Level: X-Archive-Number: 201007/792 X-Sequence-Number: 165677 Works! The bug in my example was not passing the INSERT statement an explicit list of column names, as per any non-prepared insert. Thanks! Scott On Jul 23, 2010, at 2:53 PM, Daniel Verite wrote: > Scott Frankel wrote: > >> I've found that, for a table with a >> serial sequence key as its first column, I have to specify the key in >> my prepared statement or I get type errors: ERROR: column "foo_id" >> is of type integer but expression is of type character varying. > > Let's try: > > test=> create table t(a serial, b int); > NOTICE: CREATE TABLE will create implicit sequence "t_a_seq" for > serial > column "t.a" > CREATE TABLE > test=> prepare a as insert into t(b) values($1); > PREPARE > test=> execute a(2); > INSERT 0 1 > test=> select * from t; > a | b > ---+--- > 1 | 2 > (1 row) > > No error here... > > Best regards, > -- > Daniel > PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >