•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 392,083 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,948 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser:
Views: 4152 | Replies: 4
![]() |
•
•
Join Date: Jun 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
hello...
i have a little problem about how to create an auto-increment process. i'm using an oracle and all the table and data is already exist in my database. I have seen a few example from internet and it is like this.
table users {
id int(13) not null auto_increment,
name varchar( 45 ) not null default '',
email varchar( 55 ) not null default '',
website varchar( 100 ) not null default '',
primary key( id )
}
create sequence test_seq
start with 1
increment by 1
nomaxvalue;
create trigger test_trigger
before insert on barkod
for each row
begin
Select test_seq.nextval into:new.barkod from dual;
end;
should i follow this example even all the tables and data are already exist in my database?? hope anyone in here can show step by step how to create it.
~really need help her...
~thank you...
i have a little problem about how to create an auto-increment process. i'm using an oracle and all the table and data is already exist in my database. I have seen a few example from internet and it is like this.
table users {
id int(13) not null auto_increment,
name varchar( 45 ) not null default '',
email varchar( 55 ) not null default '',
website varchar( 100 ) not null default '',
primary key( id )
}
create sequence test_seq
start with 1
increment by 1
nomaxvalue;
create trigger test_trigger
before insert on barkod
for each row
begin
Select test_seq.nextval into:new.barkod from dual;
end;
should i follow this example even all the tables and data are already exist in my database?? hope anyone in here can show step by step how to create it.
~really need help her...
~thank you...
Last edited by mawarzinnirah : Jun 25th, 2007 at 8:45 pm.
•
•
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation:
Rep Power: 4
Solved Threads: 78
•
•
Join Date: Feb 2007
Location: London
Posts: 114
Reputation:
Rep Power: 2
Solved Threads: 8
It's definately Oracle. The first statement there is not actually valid, it's just describing the existing table for you The next one creates an incrementing sequence, however I would never use a trigger to implement it as you can't find out what the value of the sequence is without requerying the table. Then you have to rely on the line being easily identifiable without having it's primary key, pretty ugly. Create the sequence and in your business logic when you insert select the nextval and save it to a variable, then insert the line with that variable value as the key field. Then you know what line in the database you should be looking at.
•
•
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation:
Rep Power: 4
Solved Threads: 78
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
Similar Threads
- How to auto increment reference number with char(9)? (VB.NET)
- How to auto increment? (ASP.NET)
- Need to know how to create a database that will generate a random number (Database Design)
Other Threads in the Oracle Forum
- Previous Thread: Oracle Help Needed
- Next Thread: Dynamic Table name



Linear Mode