paging and insert into database