question about how to handle if row exists

From: jayderk (jayderk_at_hotmail.com)
Date: 12/27/04


Date: Mon, 27 Dec 2004 10:25:51 -0600

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



Relevant Pages

  • Re: SQLCE performance from .NET CF v2.0
    ... Please remember when bulk inserting is being executed against SQL CE, ... > local database functionality. ... > database technology and I am considering switching to SQLCE at the same ... > execute the prepared statement again. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Is it just me or are there BIG problems with SQLCE 3.0?
    ... One trick you might try is to keep a connection to the database open. ... If you use the Open update Close technique, the database is compressed at the final close. ... issues with SQLCE 3.0 as opposed to SQLCE 2.0. ... days whilst constantly inserting into the ...
    (microsoft.public.sqlserver.ce)
  • Re: Data access perfomance
    ... > Hi, thanks I kind reduce the time inserting into the database, the problem ... > was that I had a primary key on the table, ... If you build a new command object for each row you insert, ...
    (microsoft.public.data.oledb)
  • question about how to handle if row exists
    ... Since this is not supported in SQLCE ... what is the recommended way of inserting new rows in the database with a ... customer_id is a primary key ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Is it just me or are there BIG problems with SQLCE 3.0?
    ... We have experienced the same problems in our app which is in production. ... are uppdating the database very often by getting data from our SQL Server. ... issues with SQLCE 3.0 as opposed to SQLCE 2.0. ... days whilst constantly inserting into the ...
    (microsoft.public.sqlserver.ce)

Loading