I am trying to insert a set of attribute rows into a table based on the range of a unique key (product_id) and three passed variables. This is on a MySQL database. The three variables are the start_product_id, the end_product_id and the batch_attr_id.
The stored procedure does not return an error, but it does not product any inserts.
code start here ---------------
insert into `product_attribute` (`product_id`, `attribute_id`, `language_id`, `text`)
(
SELECT a.`product_id`
,b.`attr_id`
,b.`lang_id`
,b.`attr_value`
FROM `product` a
,`batch_attr_detail` b
,`batch_attr_set` c
WHERE c.`batch_attr_id` = @`batch_attr_id`
and c.`batch_attr_id` = b.`batch_attr_id`
and a.`product_id` between @`start_product_id` and @`end_product_id`
);
--------------end of code
------------------------
I am calling the stored procude with this syntax -
call batch_update_proc(575,576,112);
There are records with both 575 and 576 as product IDs and the batch set 112 exists. If I take the select out of the procedure and substitute scalars, it works fine. Just no insert.
Can any one please tell me what stupid error I am making? I have spent hours on this!
Thx - Kat