• 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: Arturo Pérez <email@hidden>
  • Date: Mon, 28 Nov 2005 07:51:28 -0500

How about a stored procedure or trigger?

-arturo

On Nov 28, 2005, at 5:09 AM, Ondra Cada wrote:

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:
email@hidden


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


References: 
 >Semi-unique column (From: Ondra Cada <email@hidden>)

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