db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Myraddin <myrad...@gmail.com>
Subject javaDB IDENTITY column and INSERTS
Date Sun, 16 May 2010 10:11:38 GMT
Hi all.
My first post so bare with me if I have chosen the wrong place to ask.

I created a table in JavaDB like this:

Code:

CREATE TABLE DIRECTION(
  DIRECTION_ID INT PRIMARY KEY NOT NULL GENERATED DEFAULT AS IDENTITY,
  SOURCE_AREA_ID      INT NOT NULL
);

(it's a bit shortened but will prove my point.

Now I would like to throw in some data by using INSERT with a SELECT query
like this:

Code:

INSERT INTO DIRECTION
   SELECT AREA_ID
    FROM FOOBAR_AREA;

The error thrown is (as expected): The number of values assigned is not the
same as the number of specified or implied columns.

Then I try:
Code:

INSERT INTO DIRECTION
   SELECT {auto|default|xxx?},AREA_ID
    FROM FOOBAR_AREA;

and nothing helps.

How DOES one do an INSERT using select query into a table with an
auto-generated identity column ?

Thanks !

Mime
View raw message