1

I am using UniDac and I perform an Update instruction on MySQL server. I am doing it simultaneously by two clients. I wanted to know who updated record in the first place, so I was checking parameter RowsAffected and I thought that if one peer will perform it before the second one I will get RowsAffected>0 only on the first peer. The problem is that I get RowsAffected>0 on both clients. How to omit this problem?

Flash
  • 466
  • 6
  • 16
  • What makes you think the second peer would not be able to update the same records? What do your SQL queries looks like? Does the first peer's update change values that the second peer's query is looking for? – Remy Lebeau Apr 29 '15 at 17:55
  • `RowsAffected` is only from a client correctly evaluated that made an update or insert. Only after these commands can with `RowsAffected` checked how many "rows" were affected by this command. Client 2 is responsible for his changes to the database itself, and therefore sees only his made changes. client2 can never see with `RowsAffected` what client1 has done. If `RowsAffected>0` client2 must made changes to DB too. – moskito-x Apr 29 '15 at 18:15
  • `RowsAffected` is perfectly reliable. Your understanding of what it does is flawed. Not everything that you don't understand is a bug or unreliable or broken; it simply means you don't understand what it does, what it's for, or how to use it. – Ken White Apr 29 '15 at 18:18
  • I found the reason for that behavior. Maybe RowsAffected is reliable but not in DevArt components. RowsAffected behaves like RowsMatched (it is confirmed by DevArt support) I even checked "select row_count()" and it acts like RowsMatched. I have no idea why... – Flash Apr 30 '15 at 08:18

1 Answers1

0

https://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_row-count : ...The ROW_COUNT() value is similar to the value from the mysql_affected_rows()...

  • I have already tested this function and it still behaves as rows_matched. Is there any other way to examine which peer made change? The new value in both connections will be the same, but I need to know who did the change first. – Flash Apr 30 '15 at 08:57
  • RowsAffected in DevArt components is reliable - it returns the number of rows changed, deleted, or inserted by the LAST STATEMENT if it was an UPDATE, DELETE, or INSERT. https://dev.mysql.com/doc/refman/5.0/en/mysql-affected-rows.html – Developer Apr 30 '15 at 09:23
  • http://forums.devart.com/viewtopic.php?t=340 it says it doesnt compare if data was changed. I have the same observation and have the latest version of UniDac. RowsAffected returns 1 ALWAYS no matter if the old value was the same as new one. – Flash Apr 30 '15 at 10:21