Sometimes it's desirable to first to a SELECT to see if a row exists, and then INSERT if it doesn't already, or UPDATE if it does.
MySQL's got a really handy 'REPLACE INTO' for just this circumstance, some have suggested that PostgreSQL should support this in future. Your solution looks good. Stuart.
