On Feb 14, 2007, at 10:14 PM, Dennis Birch wrote:

I'm experimenting with adding a database component to a project. I've
arrived at a point where I could go one of two ways to deal with an
issue, and I'm not sure what the best approach is.

I have a TEXT column in one table that has a UNIQUE constraint, to
create a unique list of words. The interface allows users to update
the list after it's initially created, so there's a potential for them
to try to add a word to the list that the table already contains.

It seems to me there are two ways to handle this (and there are
probably more I'm totally oblivious to). I could check in advance to
see if a word is already in the list by doing a SELECT for that word,
and then skipping my INSERT if the SELECT is successful. Or I could
just INSERT the word and ignore the error if it's a constraint
violation (UNIQUE is the only constraint on that column).

I hope some database gurus can advise me. Is there a better way of
doing this? Is one of these ways preferable to the other?

If it makes any difference, I'm using the REALSQLDatabase for this.

Or you can use REPLACE INTO which will do an update if it already exists or add it if not
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to