Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

AutoNumber datatype(using JDBC)

  Asked By: Dora    Date: Jan 14    Category: Java    Views: 2045

I am using seqno field in access(with jdbc),which uses AutoNumber as datatype.and Which increments itself if i add any new record.

The problem is with my deletion of record,if i delete some records,there so no changes in seqno because it just increments itself.

But i want seqno should also update itself,if i delete any records.can anybody tell me wht i should do to solve this problem.



2 Answers Found

Answer #1    Answered By: Bathilda Schmidt     Answered On: Jan 14

updating IDs after delete  is considered a very bad practice. i suggest u not to do that. there are ways like:
lock the table, fetch the whole table, write the records  again with new IDs.
but u have to free ur design from this.
a better way is to have a code field  and work with that.
if u delete a recorde u may find the deleted code and reuse it.this has nothing to do with the ID.
Have More Fun.

Answer #2    Answered By: Joyce Edwards     Answered On: Jan 14

Basically, when you're using AutoNumber for your table, you are implicitly creating a dummy primary key for your table without counting on further modification of this field  and you haven't any concern about the values. If you need to manipulate your key values (update or reuse them), then you must go for manual code generation through your program. It always recommendable.

Didn't find what you were looking for? Find more on AutoNumber datatype(using JDBC) Or get search suggestion and latest updates.