Subject | Inserting records where primary key exists (opinion) |
---|---|
Author | rodbracher |
Post date | 2005-03-15T08:30:36Z |
Hi
If I can expect to have certain records inserted, but the primary key
already exists, is it ok to get the exception and ignore the insert.
OR
Is it better practice to query the db, check if the record exists, if
it does ignore the insert.
(Its a case where I never want to update a record if it has been
inserted already.)
I know either way will work, it just seems like the second option may
create more 'work' for the database - or is it the other way around?
Thanks
Rod
If I can expect to have certain records inserted, but the primary key
already exists, is it ok to get the exception and ignore the insert.
OR
Is it better practice to query the db, check if the record exists, if
it does ignore the insert.
(Its a case where I never want to update a record if it has been
inserted already.)
I know either way will work, it just seems like the second option may
create more 'work' for the database - or is it the other way around?
Thanks
Rod