Is there any database only (currently I'm doing this in perl) solution
to update a record or insert it if criteria isn't met:

for example, I have a table:

mysql> describe tblHits;
+------------+----------------------+------+-----+---------+-------+
| Field      | Type                 | Null | Key | Default | Extra |
+------------+----------------------+------+-----+---------+-------+
| iListingID | int(11)              |      | PRI | 0       |       |
| iHits      | smallint(5) unsigned |      |     | 0       |       |
+------------+----------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

I want to increment iHits with an update statement if the iListingID
exists, otherwise, create a record with one hit.

Currently I have perl figure this out with obvious locking issues (which
I assume will be cured by my imminent move to innodb).  Normally I would
use a stored procedure, but I'm not sure if there's a mysql solution to
this.  If there isn't, I think it would be a very beneficial thing to
put on the todo list.



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to