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.
A:
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
2009-05-20 11:18:22
A:
If you're using JavaDB you need the GENERATED AS IDENTITY
option on a field in your CREATE TABLE
statement.
Dave Webb
2009-05-20 11:35:19
A:
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
2009-06-05 23:09:18