• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Semi-unique column
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Semi-unique column


  • Subject: Re: Semi-unique column
  • From: Anjo Krank <email@hidden>
  • Date: Mon, 28 Nov 2005 13:00:40 +0100

Refactor your table and move the unique stuff to an extra table and enforce the DB-level uniqueness there?

Am 28.11.2005 um 11:09 schrieb Ondra Cada:

Hello,

My current customer needs a column which is semi-unique, i.e., some of its values (programmatically determined which ones, in this case those which happen to contain a decimal digit) need to be unique, whilst others need not.

Of course, I can easily write a Java code to handle this kind of "uniqueness", something conceptually like

void testAndSave() {
String uval=changedObject.uniqueValue();
if (shouldBeUniqueValue(uval)) {
NSArray a=EOUtilities.objectMatchingKeyAndValue (changedObject.editingContext(),"uniqueValue",uval);
if (a.count()>0) throw new Exception("Not unique "+uval);
}
changedObject.editingContext().saveChanges();
}


I don't quite like this code though, for there still is a slight possibility for two concurrent clients' operations may be ordered so that both tests are all right, and then non-unique values are saved. Since only some values are to be uniqued, I cannot use a database unique constraint to prevent that (incidentally, am using FrontBase -- not that it is important in this case).

What would be the best solution? Is there a standard way to make such a test and save an atomical operation? I could lock or create an explicit transaction I guess, but at the first look it seems to be a bit overkill for such a plain task?

Thanks for any idea,
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40logicunited.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Semi-unique column
      • From: Ondra Cada <email@hidden>
References: 
 >Semi-unique column (From: Ondra Cada <email@hidden>)

  • Prev by Date: Semi-unique column
  • Next by Date: Re: Semi-unique column
  • Previous by thread: Semi-unique column
  • Next by thread: Re: Semi-unique column
  • Index(es):
    • Date
    • Thread