RSS Forums RSS

Autogenerated Primary Key.. Pls Help !!

Please support our Oracle advertiser: Programming Forums
Reply
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 !!

  #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.
AddThis Social Bookmark Button
Reply With Quote  
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 !!

  #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  
Posts: 1,858
Reputation: debasisdas is on a distinguished road 
Solved Threads: 113
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Posting Virtuoso

Re: Autogenerated Primary Key.. Pls Help !!

  #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  
Reply

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



Other Threads in the Oracle Forum
Views: 915 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:08 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC