How can I update a row in an SQL table instead adding an addition row. For example I have a table named Machine
having columns MachineName
, ProgramName
, RightCount
, LeftCount
. In first row it has some values. I am fetching the value from a text file. In case if there is a change in RightCount. It has to update the same row instead adding a new row with all the same data.
I tried and have groovy-sql code as: This inserts new row when there is any change in data. How can I achieve updating a single row instead adding new row.
def map = ["MachineName": e.getMachineName(),
"ProgramName": e.getProgramName(),
"RightCount": e.getRightCount(),
"LeftStentCount": e.getLeftCount()]
def stat = "Insert Into [try].[dbo].[Machine] (MachineName,ProgramName,RightCount, LeftCount) VALUES (:MachineName, :ProgramName:RightCount, :LeftCount)"
def result = sql.executeInsert(map, stat)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…