The below code always returns value 2(result = stmt.execute()) but the data in the tables are getting inserted/ updated perfectly, so shoudnt the below code return the value 0 instead of 2. please correct me if my understanding is wrong.
Code
auto con = new GetConnections();
ini result;
Statement stmt = con.db.prepare("INSERT INTO test (Hostname,Location,Rack,Updated)
VALUES(:Hostname,:Location,:Location,:Updated)
ON DUPLICATE KEY UPDATE
Location = IF(Location != VALUES(Location), VALUES(Location), :Location),
Rack = IF(Rack != VALUES(Rack), VALUES(Rack), :Rack),
Updated = :Updated");
foreach(i,ref h,ref l,ref r; lockstep(data["Hostname"][], data["Location"][], data["Rack"][])) {
stmt.setParameter("Hostname", data["Hostname"][i]);
stmt.setParameter("Location", data["Location"][i]);
stmt.setParameter("Rack", data["Rack"][i]);
stmt.setParameter("Updated", Clock.currTime().toISOExtString()[0..19]);
result = stmt.execute();
}
con.db.close();
Hi All,
The below code always returns value 2(result = stmt.execute()) but the data in the tables are getting inserted/ updated perfectly, so shoudnt the below code return the value 0 instead of 2. please correct me if my understanding is wrong.
Code