From: Scott Frankel <frankel@circlesfx.com>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: PostgreSQL List <pgsql-general@postgresql.org>
Subject: Re: prepared statements
Date: Fri, 23 Jul 2010 16:32:17 -0700
Message-ID: <022BE477-69E6-41FD-9455-C1A7756B19F0@circlesfx.com> (raw)
In-Reply-To: <25ac0333-7cf9-4410-9c43-fba7815bb918@mm>
References: <25ac0333-7cf9-4410-9c43-fba7815bb918@mm>
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
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: frankel@circlesfx.com, daniel@manitou-mail.org
Subject: Re: prepared statements
In-Reply-To: <022BE477-69E6-41FD-9455-C1A7756B19F0@circlesfx.com>
References: <25ac0333-7cf9-4410-9c43-fba7815bb918@mm> <022BE477-69E6-41FD-9455-C1A7756B19F0@circlesfx.com>
* 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