Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1086

Batch insert inserts only the first row when there is a trigger

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              Elyor Elyorbek Ibrokhimov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.