Re: primary key error with PostgreSQL

[prev] [thread] [next] [Date index for 2005/05/22]

From: Sam Kelly
Subject: Re: primary key error with PostgreSQL
Date: 01:09 on 22 May 2005
On 5/21/05, Cees Hek <ceeshek@xxxxx.xxx> wrote:
> On 5/20/05, Sam Kelly <samuel.kelly@xxxxx.xxx> wrote:
> > I dropped the table (no foreign keys) and recreated it with this:
> >
> > meal=3D> CREATE TABLE item (
> > meal(>     itemid SERIAL PRIMARY KEY,
> > meal(>     description TEXT,
> > meal(>     qty INTEGER
> > meal(> );
> > NOTICE:  CREATE TABLE will create implicit sequence "item_itemid_seq"
> > for "serial" column "item.itemid"
> > NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
> > "item_pkey" for table "item"
> > CREATE TABLE
> > meal=3D> \q
> >
> > I still get the exact same error message :-(. I notice the SQL in the
> > error message includes itemid in the field list for the INSERT. Does
> > Class::DBI actually ask the database what the primary key is or does
> > it just use the first element in the fields list? Either way it should
> > work, right?
>=20
> Are you telling Class::DBI about the new sequence?
>=20
> __PACKAGE__->sequence('item_itemid_seq');
>=20
> If you want this stuff to be configured automatically then you can use
> the Class::DBI::Pg module to automatically configure the table for you
> with the set_up_table method.
>=20
> __PACKAGE__->set_up_table('item');
>=20
> Cheers,
>=20
> Cees
>=20

Thanks Cees, that worked! I used set_up_table. Shoud the other way
have worked anyway? If it should have, it probably didn't because I
had already inherited from Class::DBI::Pg anyway which probably
changed the behavior of the columns method.

Also, for PostgreSQL users, make sure you remember that AutoCommit is
false by default for PostgreSQL databases. Else your program may not
show any errors or warnings and you'll see no changes in the database.

primary key error with PostgreSQL
cesmky 06:03 on 20 May 2005

Re: primary key error with PostgreSQL
Tony Bowden 06:25 on 20 May 2005

Re: primary key error with PostgreSQL
Brett Sanger 13:26 on 20 May 2005

Re: primary key error with PostgreSQL
Sam Kelly 02:49 on 21 May 2005

Re: primary key error with PostgreSQL
Cees Hek 00:13 on 22 May 2005

Re: primary key error with PostgreSQL
Sam Kelly 01:09 on 22 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52