PC Review


Reply
Thread Tools Rate Thread

question about how to handle if row exists

 
 
jayderk
Guest
Posts: n/a
 
      27th Dec 2004
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


 
Reply With Quote
 
 
 
 
Jan Yeh_eMVP
Guest
Posts: n/a
 
      29th Dec 2004
You can use plan (b) if you focus on efficiency...
Use DataReader for better performance...
--

Best Regards,

Jan Yeh
MVP - Windows CE.NET, MCSD.NET, .NETcf consultant
Web - http://www.mobilemind.com.tw , Blog - http://blog.mvpcn.net/janyeh


"jayderk" <(E-Mail Removed)> ¼¶¼g©ó¶l¥ó·s»D:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
After AppDomain.Unload(...) there still a handle exists,... Kerem Gümrükcü Microsoft C# .NET 0 9th Mar 2009 02:50 AM
"Window handle already exists" exception when setting ErrorProvide Flack Microsoft Dot NET Framework Forms 0 29th Mar 2008 01:48 AM
Exists Question ThePandaManCan Microsoft Access Queries 1 1st Sep 2006 07:54 PM
How to use File.Exists and Handle Insufficient Permissions =?Utf-8?B?Q2hyaXMgRmluaw==?= Microsoft C# .NET 2 29th Sep 2005 04:50 PM
window handle already exists René Iversen Microsoft C# .NET 8 28th Jul 2004 02:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.