Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 65223 invoked from network); 22 Feb 2005 19:44:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 22 Feb 2005 19:44:21 -0000 Received: (qmail 34324 invoked by uid 500); 22 Feb 2005 19:44:20 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 34303 invoked by uid 500); 22 Feb 2005 19:44:20 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 34289 invoked by uid 99); 22 Feb 2005 19:44:20 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from e5.ny.us.ibm.com (HELO e5.ny.us.ibm.com) (32.97.182.145) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 22 Feb 2005 11:44:19 -0800 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e5.ny.us.ibm.com (8.12.11/8.12.11) with ESMTP id j1MJiG7A021251 for ; Tue, 22 Feb 2005 14:44:16 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay02.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j1MJiGSF048826 for ; Tue, 22 Feb 2005 14:44:16 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j1MJiGrt014140 for ; Tue, 22 Feb 2005 14:44:16 -0500 Received: from [127.0.0.1] (sig-9-48-127-118.mts.ibm.com [9.48.127.118]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j1MJiDjx013997 for ; Tue, 22 Feb 2005 14:44:16 -0500 Message-ID: <421B8B54.8080906@Sourcery.Org> Date: Tue, 22 Feb 2005 11:43:16 -0800 From: Satheesh Bandaram User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Re: identity column causes grief when populating table - suggestions? References: <421B8A3F.2090908@protocool.com> In-Reply-To: <421B8A3F.2090908@protocool.com> X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N You are trying to insert into a column that is declared as identity. Database automatically generates a unique number for identity columns, so just leave out ID column in your INSERT statement, like: insert into sample (DESCRIPTION, QUANTITY) values ('blah', 1.1); That should fix it... Satheesh Trevor Squires wrote: > Hi, > > I've been googling all morning and can't find info to solve this > problem (using derby of course), I hope someone here can help... > > As I write my application I have a script which blats and recreates my > database and then populates the tables with test data. > > However, many of my tables have identity columns and it's causing the > following error when I insert the data: > > 11:06:26 [INSERT - 0 row(s), 0.016 secs] [Error Code: 30000, SQL > State: 42Z23] Attempt to modify an identity column 'ID'. > > Here's my table: > > create table sample ( > id int not null generated always as identity, > description varchar(128) not null, > quantity double not null, > constraint product_pk primary key (id) > ); > > Here's my insert statement > > insert into sample (ID, DESCRIPTION, QUANTITY) values (1, 'blah', 1.1); > > I've tried to create the table without "generated always as identity" > and then altering the table after the insert(s). > > Unfortunately I can't get the syntax right and I can't figure out if > there's a way to turn off identity generation temporarily. > > Does anyone have any suggestions like pointer to the right way to do > this or a relatively painless workaround? > > Thanks for listening, > Trevor > > >