Volkovlabs Data manipulation, insert/update more than 1 table

I use Data manipulation from Volkovlabs and now i want to update 2 tables in my mysql-database.

This is what i have tried

const payload = {};

elements.forEach((element) => {
  if (!element.value) {
    return;
  }

  payload[element.id] = element.value;
});

// Create a object for each SQL-question
const queryInsert = {
  rawSql: `INSERT INTO anc_test_result (fid, result, comment, user) VALUES ('${payload.fid}', '${payload.result}', '${payload.comment}', '${__user.id}')`,
  format: 'table',
};

const queryUpdate = {
  rawSql: `INSERT INTO anc_test_status (fid, status) VALUES ('${payload.fid}', 'Test incomming') ON DUPLICATE KEY UPDATE status = VALUES(status)`,
  format: 'table',
};

// Return a list with the separate SQL-question.
return [queryInsert, queryUpdate];

and when i run each of them separately they work.

Is this even possible to do?

The problem is that the value for status is a static text and could be different for different sql-querys

Thanks! I had not work with stored procedures before, but when i read about and test it, it work at first try. Thanks!

1 Like