database - MySQL dbCursor not working -
here's code. trying move cart items order items table. possibly wrong not working?
create procedure `insert_order_details` (in `customer_id` varchar(255), in `order_id` varchar(255), in `shipping_country` varchar(255), in `shipping_state` varchar(255), in `shipping_address` varchar(255)) begin declare v_finished integer default 0; declare product_id varchar(255); declare quantity integer; declare unit_price integer; declare cart_cursor cursor select @order_id, product_id , quantity, unit_price, userid cart userid=@customer_id , status = 'pending'; declare continue handler not found set v_finished = 1; open cart_cursor; read_loop: loop fetch cart_cursor order_id, product_id, quantity, unit_price, customer_id; if v_finished = 1 leave read_loop; end if; insert order_details (order_id,product_id, quantity, unit_price, customer_id,shipping_country,shippping_state, shipping_address) values (@order_id,product_id, quantity, unit_price, @customer_id, date_added,@shipping_country,@shipping_state,@shipping_address) ; end loop read_loop; close cart_cursor; end
you're referring user variable @order_id in cursor, while want use stored procedure variable order_id instead.