High all
I am using the folloiwing sql to update the results of my tests to a mysql db. I wish to only update if the test exist all ready. If it doesn't exist then insert. (As you will see in my statement.) Anyways it does not update if the test exist all ready. It is always inserting.
NSERT INTO metrics (testdate,folder,testname,alive) VALUES (NOW(), '%Folder%', '%TestName%', '%AliveRatio%') ON DUPLICATE KEY UPDATE testdate=NOW(), folder='%Folder%',testname='%testname%',alive='%AliveRatio%'
ODBC MYSQL UPDATE LOGGING
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Re: ODBC MYSQL UPDATE LOGGING
Correct.ericm wrote:It is always inserting.
"AliveRatio" is changed every time the test has been performed, so DUPLICATE KEY UPDATE wil not work in such case. Try to use following syntax:ericm wrote:NSERT INTO metrics (testdate,folder,testname,alive) VALUES (NOW(), '%Folder%', '%TestName%', '%AliveRatio%') ON DUPLICATE KEY UPDATE testdate=NOW(), folder='%Folder%',testname='%testname%',alive='%AliveRatio%'
Code: Select all
INSERT INTO metrics (testdate,folder,testname,alive) VALUES (NOW(), '%Folder%', '%TestName%', '%AliveRatio%') ON DUPLICATE KEY UPDATE testdate=NOW(), folder='%Folder%',testname='%testname%'
Regads,
Max