1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| delimiter $$
drop procedure if exists table_copie$$
create procedure table_copie(in source varchar(64),in destination varchar(64),in id_nom varchar(64), in quantite int unsigned)
begin
set @req=concat('insert into `',destination,'` select * from source limit ',quantite);
prepare exe from @req;
execute exe;
deallocate prepare exe;
set @req=concat('select max(`',id_nom,'`) into @n from `',destination,'`');
prepare exe from @req;
execute exe;
deallocate prepare exe;
set @req=concat('delete from `',source,'` where `',id_nom,'`<=',@n);
prepare exe from @req;
execute exe;
deallocate prepare exe;
end$$
delimiter ; |
Partager