i am trying to code for my system in NetBeans IDE 6.5 to auto generate ID numbers for me like autonumbers in Ms Access. does any one have any ideas about going about that?i mean code for it.
Asked
Active
Viewed 245 times
0
-
I really don't think the MS-ACCESS tag adds anything here, as the question isn't about Access or Jet or ACE, but about how to do something like that in a different environment. In other words, Access is not relevant to the answer for the question at all. – David-W-Fenton Jul 03 '10 at 22:48
4 Answers
0
What database system are you using? If it's something SQL based:
CREATE TABLE $tblname (id int(10) NOT NULL auto_increment PRIMARY KEY (id))
Try using auto_increment , such as in the example above.

Alya
- 262
- 2
- 10
0
If you're using JavaDB you need the GENERATED AS IDENTITY
option on a field in your CREATE TABLE
statement.

David Webb
- 190,537
- 57
- 313
- 299
0
If you're using Oracle, you will need a sequence for each table.
once you have the sequence you can create a trigger like this:
Create or Replace trigger incrementOnInsert
before insert on TABLE
for each row
begin
select sequence.nextval into :new.id from dual;
end;

Jonathan
- 11,809
- 5
- 57
- 91