CREATE PROCEDURE maximator.proc_del_data_to_ram_table_sklad(IN sklad_id INT)
SQL SECURITY INVOKER
COMMENT 'Удаление позиций склада из RAM таблицы'
BEGIN
declare count_ INTEGER;
DECLARE shag INTEGER;
DECLARE i INTEGER ;
declare command_ VARCHAR(255);
SELECT
count(result_table_ram.id) as count_
FROM
result_table_ram where (id_sklad_postavshika=sklad_id) INTO count_ ;
if count_>0 THEN
SET shag=5000;
set i=(count_ DIV shag)+1;
REPEAT
SET @command_=concat('DELETE FROM result_table_ram where id_sklad_postavshika=',sklad_id,' LIMIT ',shag);
prepare exec_command from @command_;
EXECUTE exec_command ;
SET i=i-1;
UNTIL i<=0
END REPEAT;
end if;
END
Last edited by ism on 05.11.2012, 19:37, edited 1 time in total.