DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Oracle (http://www.daniweb.com/forums/forum129.html)
-   -   Autogenerated Primary Key.. Pls Help !! (http://www.daniweb.com/forums/thread155431.html)

lakshma.sugunan Nov 5th, 2008 7:17 am
Autogenerated Primary Key.. Pls Help !!
 
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.

yilmazhuseyin Nov 5th, 2008 11:57 am
Re: Autogenerated Primary Key.. Pls Help !!
 
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')

debasisdas Nov 5th, 2008 2:49 pm
Re: Autogenerated Primary Key.. Pls Help !!
 
you can use either a sequence or the max value of PK field +1 for the next unique not null value.


All times are GMT -4. The time now is 6:05 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC