User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Jun 2007
Posts: 4
Reputation: mawarzinnirah is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mawarzinnirah mawarzinnirah is offline Offline
Newbie Poster

how to create an auto-increment process?

  #1  
Jun 25th, 2007
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...
Last edited by mawarzinnirah : Jun 25th, 2007 at 8:45 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: how to create an auto-increment process?

  #2  
Jun 28th, 2007
I don't think that is in ORACLE.

R u sure.
Share your Knowledge.
Reply With Quote  
Join Date: Feb 2007
Location: London
Posts: 114
Reputation: davidcairns is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 8
davidcairns davidcairns is offline Offline
Junior Poster

Re: how to create an auto-increment process?

  #3  
Jun 28th, 2007
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.
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: how to create an auto-increment process?

  #4  
Jul 5th, 2007
sorry dear the statment auto_increment is not valid in oracle , so it is not it oracle but in postgre sql .Restall u can aany way define in oracle.
Share your Knowledge.
Reply With Quote  
Join Date: Mar 2007
Posts: 120
Reputation: sillyboy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
sillyboy sillyboy is offline Offline
Junior Poster

Re: how to create an auto-increment process?

  #5  
Jul 5th, 2007
Just get rid of "auto_increment".
I think it'll work with int(13), if not, just use NUMBER.
Last edited by sillyboy : Jul 5th, 2007 at 11:28 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Oracle Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Oracle Forum

All times are GMT -4. The time now is 12:28 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC