1 | | Необходимо изменить процедуры для работы ревизии №, где был исправлен баг: несоответствия должны выводить только непустые комментарии типа Запись, а выводят и пустые тоже |
| 1 | Необходимо изменить процедуры для работы ревизии r242/base, где был исправлен баг: несоответствия должны выводить только непустые комментарии типа Запись, а выводят и пустые тоже |
| 2 | |
| 3 | |
| 4 | |
| 5 | drop procedure mismatchQuery; |
| 6 | |
| 7 | DELIMITER } |
| 8 | |
| 9 | CREATE PROCEDURE mismatchQuery(min int, max int, searchName varchar (100), searchSerial varchar (100), searchComment varchar (10000)) READS SQL DATA |
| 10 | BEGIN |
| 11 | set @prevtotal := 0; |
| 12 | set @mintotal := 0; |
| 13 | select * from (select *, @mintotal as mintotal, @prevtotal := @mintotal - total as prevtotal from |
| 14 | (select products.serial, history.uid, history.date, hist1.total from history inner join |
| 15 | (select uid, count(uid) as total from history where (type_write = "mismatch" or type_write = 'record' or type_write = "repair" or |
| 16 | (type_write = "otk" and status = "fail") or (type_write = "testing" and status = "fail")) and comment is not null and comment != '' group by uid) as hist1 on history.uid = hist1.uid |
| 17 | inner join products on products.uid = history.uid where (products.name like searchName |
| 18 | and products.serial like searchSerial and history.comment like searchComment) and (history.uid, history.date) in (select uid, max(date) from history where (type_write = "mismatch" or type_write = 'record' or type_write = "repair" or |
| 19 | (type_write = "otk" and status = "fail") or (type_write = "testing" and status = "fail" )) and comment is not null and comment != '' group by uid ) |
| 20 | group by products.serial, history.uid, history.date, hist1.total order by history.date desc) as hist2 |
| 21 | where (@mintotal := @minTotal + total)) as hust2 where hust2.mintotal > min and hust2.prevtotal < max; |
| 22 | |
| 23 | END} |
| 24 | DELIMITER ; |
| 25 | |
| 26 | |
| 27 | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 28 | |
| 29 | |
| 30 | drop procedure mismatchQueryWithoutOtkRows; |
| 31 | |
| 32 | DELIMITER } |
| 33 | |
| 34 | CREATE PROCEDURE mismatchQueryWithoutOtkRows(min int, max int, searchName varchar (100), searchSerial varchar (100), searchComment varchar (10000)) READS SQL DATA |
| 35 | BEGIN |
| 36 | set @prevtotal := 0; |
| 37 | set @mintotal := 0; |
| 38 | select * from (select *, @mintotal as mintotal, @prevtotal := @mintotal - total as prevtotal from |
| 39 | (select products.serial, history.uid, history.date, hist1.total from history inner join |
| 40 | (select uid, count(uid) as total from history where (type_write = "mismatch" or type_write = 'record' |
| 41 | or type_write = "repair" or (type_write = "testing" and status = "fail")) and comment is not null and comment != '' group by uid) as hist1 on history.uid = hist1.uid |
| 42 | inner join products on products.uid = history.uid where (products.name like searchName |
| 43 | and products.serial like searchSerial and history.comment like searchComment) and (history.uid, history.date) in |
| 44 | (select uid, max(date) from history where (type_write = "mismatch" or type_write = 'record' or type_write = "repair" or |
| 45 | (type_write = "testing" and status = "fail") or `history`.type_write = 'record') and comment is not null and comment != '' group by uid) |
| 46 | group by products.serial, history.uid, history.date, hist1.total order by history.date desc) as hist2 |
| 47 | where (@mintotal := @minTotal + total)) as hust2 where hust2.mintotal > min and hust2.prevtotal < max; |
| 48 | |
| 49 | END} |
| 50 | DELIMITER ; |