• 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: validate the uniqueness of data first before inserting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: validate the uniqueness of data first before inserting


  • Subject: Re: validate the uniqueness of data first before inserting
  • From: Ashley Aitken <email@hidden>
  • Date: Wed, 16 Jun 2004 21:04:26 +0800

On 16/06/2004, at 8:43 PM, Patrick Robinson wrote:

On Jun 16, 2004, at 6:09 AM, Ashley Aitken wrote:
On 16/06/2004, at 5:32 PM, Goh Keng Boon wrote:
I got this field called customer_code which is keyin by user manually and it need to be unique. How can it check if it is unique first
before inserting the whole record into database?

Try and fetch an object/record with the same value for customer_code ...

The problem with this approach is that someone else could insert a row with your customer_code value after you check for it, but before your insert fires.


This is a case where it's nice when you can depend on the database to enforce constraints... you can catch any resulting exceptions, and handle appropriately.

Yes, that's true. Thus, if this was likely and would cause a significant problem (ie it couldn't be easily fixed without significance at a later time) then one could either lock the database table between the before the fetch and until the row is saved, or as you suggest perhaps use a database-specific constraint on a column .


Cheers,
Ashley.

--
Ashley Aitken
Perth, Western Australia
mrhatken at mac dot com
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >validate the uniqueness of data first before inserting (From: Goh Keng Boon <email@hidden>)
 >Re: validate the uniqueness of data first before inserting (From: Ashley Aitken <email@hidden>)
 >Re: validate the uniqueness of data first before inserting (From: Patrick Robinson <email@hidden>)

  • Prev by Date: Help! EOModler doesnt start
  • Next by Date: Re: NSCombobox
  • Previous by thread: Re: validate the uniqueness of data first before inserting
  • Next by thread: Time issue again(time out value was set to 4 hours,but time out only one miniute)
  • Index(es):
    • Date
    • Thread