Results 1 to 4 of 4
- 05-15-2010, 05:11 PM #1
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
javaDB IDENTITY column and INSERTS
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:
(it's a bit shortened but will prove my point.Java Code:CREATE TABLE DIRECTION( DIRECTION_ID INT PRIMARY KEY NOT NULL GENERATED DEFAULT AS IDENTITY, SOURCE_AREA_ID INT NOT NULL );
Now I would like to throw in some data by using INSERT with a SELECT query like this:
The error thrown is (as expected): The number of values assigned is not the same as the number of specified or implied columns.Java Code:INSERT INTO DIRECTION SELECT AREA_ID FROM FOOBAR_AREA;
Then I try:
and nothing helps.Java Code:INSERT INTO DIRECTION SELECT {auto|default|xxx?},AREA_ID FROM FOOBAR_AREA;
How DOES one do an INSERT using select query into a table with an auto-generated identity column ?
Thanks !
- 05-16-2010, 05:47 AM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
First wellcome :)
I am afraid it is not Java question but SQL one :(
Anyway... If your table contains X columns you have to INSERT X params. Either they would be null or not it doesn't matter...If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 05-16-2010, 11:21 AM #3
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
Thank you Webuser.
I saw a few posts about JavaDB on these forums so ... i thought...
Never mind then.
As for you reply it's not actually related to my question but thank you for trying ;)
Happy coding.
- 05-16-2010, 10:53 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Have you tried simply
Seeing as how when you only give it one value when the table has two columns, the DB is not going to take responsibility for the action (and consequences) and attempt to "guess" at which column should be getting the value provided.Java Code:INSERT INTO DIRECTION (SOURCE_AREA_ID) SELECT AREA_ID FROM FOOBAR_AREA;
Similar Threads
-
insert row and column and delete row and column
By daredavil82 in forum New To JavaReplies: 13Last Post: 09-22-2011, 06:10 PM -
IBM Tivoli Identity Manager
By pooja_k in forum Jobs OfferedReplies: 0Last Post: 01-11-2010, 06:29 AM -
JavaDB Help
By Sysem in forum New To JavaReplies: 5Last Post: 05-29-2008, 09:21 PM -
JavaDB Installation
By PhilArmstrong in forum New To JavaReplies: 6Last Post: 05-13-2008, 02:09 PM -
how to count 2 inserts together?
By kim85 in forum New To JavaReplies: 0Last Post: 01-20-2008, 11:25 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks