MySQL mysql_info alike message within a stored procedure (both affected and matched row counts) -


i trying figure out how both affected row count , matched row count within stored procedure after update query. aware of row_count function, returns number of rows changed query. how number of rows matched update query?

row_count() - returns number of changed rows found_rows() - works select ... limit query diagnostics x = row_count - returns same row_count() diagnostics x = number - returns 0 diagnostics condition 1 x = message_text - returns null on success 

in php there mysqli_info() method, returns great result on update:

rows matched: 40 changed: 38 warnings: 0 

so, how message (or these 2 values - rows matched , rows changed) within stored procedure?

or forced run select query same clause before update number of matched rows? can value returned select query trustful when run before actual update? can table change while stored procedure running? or should lock table?

consider mysql 5.7.

thanks.

update

the best solution found far (pseudocode):

declare _rows_matched, _rows_affected int;  start transaction;  select count(1) _rows_matched tbl {condition x} update; update tbl set {sets...} {condition x}; select row_count() _rows_affected;  commit;  select _rows_matched, _rows_affected; 

does select count() ... update give me concurency-proof number of matched rows until update made?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -