On Feb 8, 2010, at 4:04 PM, Nate Lowrie wrote:

> You think that's better than writing a select statement query with a 
> where clause that filters on the column value?  I want to try to 
> incorporate the uniqueness validation inside the validateRecord because 
> I do all the validation there and display all the errors to the user at 
> once on the dialog.  I would still handle the DBQueryException, I would 
> just want a way of bundling the uniqueness check in with the other 
> business rules.

        Sure, you could do it that way; if I were doing it, though, I would 
only make that extra query if it were very likely that there would be a dupe. 
It's like the general approach to protecting against bad parameters: you could 
run the test every single time the code gets called, or you can catch the 
exception and deal with it then. The former tends to be much slower than the 
latter, and should generally be avoided.

        Also, in a multi-user situation, two people could be adding the same 
value at nearly the same time. Both would pass the validateRecord() test, but 
only one will actually be able to save, so I'm not really sure what benefit 
making that extra call is getting you.


-- Ed Leafe



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to