Mysql Stored procedure write paging Program/* Paging Program */delimiter // drop procedure if exists sp_page; create procedure sp_page (p_table_name varchar (1024), p_fields varchar (1024), p_page_size int, p_curr_page int, p_order_string varchar (256), p_where_string varchar (1024), out p_total_rows int) not deterministic SQL security definer comment 'paging Stored Procedure 'www.2cto.com begin/* variable Declaration */declare v_start_row int default 0; declare v_limit_string varchar (256 ); /* assign variable values */if p_curr_page <1 then set p_curr_page = 1; end if; set @ rows_total = 0; set v_start_row = (p_curr_page-1) * p_page_size; set v_limit_string = concat ('limit', v_start_row, ',', p_page_size); set @ total_string = concat ('select count (*) into @ rows_total from ', p_table_name, '', p_where_string); set @ query_string = concat ('select', p_fields, 'from', p_table_name,'', p_where_string, '', p_order_string,'', v_limit_string ); select @ total_string; select @ query_string;/* preprocessing */prepare stmt_count from @ total_string; execute prepare; deallocate prepare stmt_count; set region = @ rows_total; prepare stmt_query from @ query_string; execute stmt_query; deallocate prepare stmt_query; end; // call stored procedure parameter description the name of the table the number of records displayed on each page of the field to be queried the total number of records on the current page call sp_page ('t_score ','*', 10, 1, '','', @ total_rows )//