Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2003

Tip: Looking for answers? Try searching our database.

Adding unique records

Thread view: 
Ike - 21 Nov 2003 15:08 GMT
How can I do an update to a table where I dont want to allow records to have
a field(s) which occur in another record, whenm each record has a unique
integer id. For example, suppose I have a table setup as:

       "id INTEGER(11) PRIMARY KEY NOT NULL AUTO_INCREMENT," +
       "activities_id INTEGER(11)," +
       "sombody VARCHAR(60),"+
       "something VARCHAR(255),"+

and I have a record I want to INSERT to this table, but only if, say, there
is not already a record there that has both 'somebody' and 'activities_id'
in the table already.

Is there an expeditious way to do this, without examining each record in the
table? Thank you, Ike
Joe Weinstein - 21 Nov 2003 16:53 GMT
> How can I do an update to a table where I dont want to allow records to have
> a field(s) which occur in another record, whenm each record has a unique
[quoted text clipped - 11 lines]
> Is there an expeditious way to do this, without examining each record in the
> table? Thank you, Ike

Sure. create a unique index for the table on (activities_id, somebody)

Joe Weinstein at BEA
Abdullah Kauchali - 23 Nov 2003 09:54 GMT
"Joe Weinstein" <joeNOSPAM@bea.com> wrote in message

> Sure. create a unique index for the table on (activities_id, somebody)

Brilliant.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.