Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

groovy - How to update a row in a Sql table

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...