Re: prepared statements

From: Scott Frankel <frankel(at)circlesfx(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: "PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: prepared statements
Date: 2010-07-23 23:32:17
Message-ID: 022BE477-69E6-41FD-9455-C1A7756B19F0@circlesfx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2010-07-24 06:09:09 Re: Problem with pg_try_advisory_lock and two connections (seemingly) getting the same lock
Previous Message John R Pierce 2010-07-23 23:14:39 Re: JASPA (JAva SPATial) for PostgreSQL and H2 released