Autogenerated Primary Key.. Pls Help !!

Reply

Join Date: Nov 2008
Posts: 2
Reputation: lakshma.sugunan is an unknown quantity at this point 
Solved Threads: 0
lakshma.sugunan lakshma.sugunan is offline Offline
Newbie Poster

Autogenerated Primary Key.. Pls Help !!

 
0
  #1
Nov 5th, 2008
When some datas are inserted in to a DB table from a jsp page, how do i get the primary key in my table autogenerated?? finiding out the highest value for the primary key in the table? Pls help me wid the coding in JAVA or HTML.. I use SQL*PLus.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 48
Reputation: yilmazhuseyin is an unknown quantity at this point 
Solved Threads: 5
yilmazhuseyin's Avatar
yilmazhuseyin yilmazhuseyin is offline Offline
Light Poster

Re: Autogenerated Primary Key.. Pls Help !!

 
0
  #2
Nov 5th, 2008
you need to create a sequence. As you can guess this is an object that gives you numbers from sequence. then you should get next value from sequence. so you will always have different pk. here is a link that shows you how to create and use it.
after creating it you will probably do something like that

insert into a(pk,col1,col2) values (sqn.nextval,'value1','value3')
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,080
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Autogenerated Primary Key.. Pls Help !!

 
0
  #3
Nov 5th, 2008
you can use either a sequence or the max value of PK field +1 for the next unique not null value.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC