views:

36

answers:

2

I have a table in mysql like this

Name              Result  
T1_09_03_2010     fail  
T2_09_03_2010     pass  
T3_09_03_2010     pass  
T4_09_03_2010     fail  
T5_09_03_2010     fail  
T6_09_03_2010     pass  
T7_09_03_2010     fail

Well, T1_09_03_2010 is testcase name. If for some reason the developer wants to test the same testcase again in the same day, using the same name then, I need a way to update the already existing row based on the result. Say , for example T1_09_03_2010 has failed in this context and if this is run again and the result is pass, it should update the row, but if the result if fail, then it should leave the result as it is I mean ignore the new insert and carry on with others.

Thanks.

+2  A: 

here is an example syntax for mysql:

INSERT INTO users (username, email) VALUES ('Jo', '[email protected]')
ON DUPLICATE KEY UPDATE email = '[email protected]'
henchman
A: 

You should use the INSERT... ON DUPLICATE KEY UPDATE .. syntax.

middaparka
Yes, I though of using thr on duplciate. But I want the condition only if the testcase fails and later passes. Will this be sufficient?
JPro
Do you really want to not know if a test case fails a second time, even if it passed the first?
Chris Ridenour
@Chris Ridenour : if the testcase is passed the first time, I want to leave the row as it is . But if it passes the second time then?
JPro
and moreover `Name` is not a primary key nor unique
JPro
From your comment, it sounds as if you want to Update the status form Fail to Pass but not from Pass to Fail. I'm just not sure why. You should be tracking the last case from all tests or recording the status of all cases (multiple rows with name, timestamp, status). Sorry if I'm not answering your specific MySQL question but I fear it is misguided as I don't understand the specific reasoning for this update logic.
Chris Ridenour
@Chris Ridenour : yes. your understanding is right. Because, it the testcase passes for first time and fails second, there is some problem with the setup env. This is up to the testers to figure it out. I just want to leave the last result to PASS
JPro