Link to home
Start Free TrialLog in
Avatar of mzlxkats
mzlxkats

asked on

insert and update

i have a text file which i want to input the data in it to a database, i means the new data be inserted and if there exists old ones, it be updated without the "key violation " error.

how to do it?

thansk

mzlxkats
Avatar of Stuart_Johnson
Stuart_Johnson

If your database is uniquely indexed, then you can do

if newdatakey=dbkey then
  update the database
else
  insert into database

If you're using a Database which has stored procedures, you can do this in one line of code in Delphi :)

Hope this helps,

Stu
Avatar of mzlxkats

ASKER

hello stu

do you have code more in detail?
ASKER CERTIFIED SOLUTION
Avatar of Stuart_Johnson
Stuart_Johnson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial