On Aug 12, 2007, at 08:39, polymath wrote:

> I would like to check if an entry for the name already
> exists in the MySQL table and if it doesn't, the program would add
> one.

A select followed by an insert statement is quiet error prone if you 
are in a multi-user environment as a row could have been inserted 
between the time your code reach the insert part.

In Oracle or such, you would use a MERGE statement [1].

In MySQL, you might be better off just using insert and catch the 
exception or perhaps try REPLACE [2] or INSERT ... ON DUPLICATE KEY 
UPDATE [3].

[1] http://www.psoug.org/reference/merge.html
[2] http://dev.mysql.com/doc/refman/5.0/en/replace.html
[3] http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to