i am trying to get record from database via stored procedure but i am getting error of
"command out of sync can not run now"
here is my stored procedure code. any buddy could help me i had waste too much time
DELIMITER $$
create procedure get_industrialchildIDs(in id int)
BEGIN
DECLARE total_rows int;
SET total_rows=0;
create TEMPORARY table IF NOT EXISTS temp_table1(CategoryChildId int(11));
truncate table temp_table1;
insert into temp_table1 SELECT CategoryChildId FROM tblcategoryparentchildassociations WHERE CategoryParentId=id;
SELECT count(CategoryChildId) into total_rows from temp_table1;
create TEMPORARY table IF NOT EXISTS temp_table (CategoryChildId int(11));
truncate table temp_table;
create TEMPORARY table IF NOT EXISTS temp_table2(CategoryChildId int(11));
insert into temp_table select id from tblmastercategories where id in (select CategoryChildId from tblcategoryparentchildassociations where CategoryParentId = id) AND flag_Industr_sub = 1;
WHILE total_rows <> 0 DO
insert into temp_table select id from tblmastercategories where id in (select CategoryChildId from tblcategoryparentchildassociations where CategoryParentId in (SELECT CategoryChildId FROM temp_table1)) AND flag_Industr_sub = 1;
delete from temp_table2 where 1=1;
insert into temp_table2 SELECT CategoryChildId FROM temp_table1;
delete from temp_table1 where 1=1;
insert into temp_table1 select CategoryChildId from tblcategoryparentchildassociations where CategoryParentId in (SELECT CategoryChildId FROM temp_table2);
SELECT count(CategoryChildId) into total_rows from temp_table1;
END WHILE;
SELECT CategoryChildId FROM temp_table;
END $$
DELIMITER ;