You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: