[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL and AutoNumber Columns

Posted on 1998-05-20
2
Medium Priority
?
482 Views
Last Modified: 2006-11-17
When using JDBC to insert into a database, how does one cope with AutoNumber Columns. What sort of SQL statement should I use?

I've tried leaving the autonumber field off - error: 'Number of query values and destination fields aren't the same'
setting the field to null - error: 'You tried to assign the Null value to a variable that isn't a Variant data type.'

I suppose that I could look up the last number each time and set the value accordingly, but this seems a little unsatisfactory.
0
Comment
Question by:binkle
2 Comments
 
LVL 7

Accepted Solution

by:
Victor Spiridonov earned 20 total points
ID: 1089953
>Number of query values and destination fields aren't the same'
From the error you getting it seems that you are leaving the filed off only in INSERT OR SELECT/VALUES part of the statement
you should not mention it at all in your insert statement. This field is handled by SQL server automatically.
0
 

Author Comment

by:binkle
ID: 1089954
Yeah - pretty dum heh?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question