|
Stackoverflow question
I have a trigger that inserts into sku_price_history table after inserting into sku table:
DELIMITER $$
CREATE TRIGGER trig_after_sku_insert
AFTER INSERT
ON sku FOR EACH ROW
BEGIN
INSERT INTO sku_price_history(sku_id, action_type, purchase_price, selling_price, base_margin_rate,
vat, vat_type, tax_type, selling_price_started_at, updated_by)
VALUES (NEW.id, 'CREATE', NEW.purchase_price, NEW.selling_price, NEW.base_margin_rate,
NEW.vat, NEW.vat_type, NEW.tax_type, NOW(), NEW.created_by);
END $$
DELIMITER ;
When I run batch inserts into sku table using PreparedStatement.addBatch() and PreparedStatement.executeBatch() it inserts only the first row. However, if I remove the trigger all the rows are inserted correctly.
|