question about how to handle if row exists

  • Thread starter Thread starter jayderk
  • Start date Start date
J

jayderk

Since this is not supported in SQLCE
"IF NOT EXISTS (SELECT customer_id FROM customer WHERE customer_id = '{0}')
INSERT INTO customer(customer_id,event_id) VALUES('{0}','{1}')

what is the recommended way of inserting new rows in the database with a
focus on efficiency?
a) do a try catch on the INSERT statement, if it fails do an UPDATE?
b) check if customer_id exists before trying to INSERT?

customer_id is a primary key


thanks in advanced.
Jay
 
Back
Top