title: Node JS, Express MySQL ES_PARSE_ERROR... "right syntax to use near '?,?,?,?,?"
body: <p>Working in Express/Node, when attempting to execute stored procedure receiving the error:</p>
  
  <blockquote>
    <p>ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to
    use near '?,?,?,?,?)</p>
  </blockquote>
  
  <p>Which makes little sense, as I have 4 or so other functions in the project doing the same thing with between 1-3 params and they all behave as expected and throw no errors.</p>
  
  <p>When attempting to run a stored procedure.</p>
  
  <p>function call:</p>
  
  <pre><code>paymentLines.forEach(async payment =&gt; {
  
  var qbid = payment.Id
  var date = payment.TxnDate
  var amount = payment.TotalAmt
  var invId = payment.Line[0].LinkedTxn[0].TxnId
  var acc = payment.DepositToAccountRef.value
  
  console.log(qbid, date, amount, invId)
  
  await service.updatePaymentDb(db, 'call qbpayments(?,?,?,?,?)', [qbid, date, amount, invId, acc])
    .then(console.log("Payment updated"))
    .catch(() =&gt; res.sendStatus(500))
  </code></pre>
  
  <p>})</p>
  
  <p>The actual function (in separate file, imported):</p>
  
  <pre><code>updatePaymentDb: function (db, proc, qid, date, amount, invId, acc) {
      return new Promise(function(resolve, reject) {
          db.query(proc, invId, date, amount, acc,  qid, (error, res) =&gt; {
          if (error) {
              reject(error);
          } else
          resolve(res);
        })
    })
  }
  </code></pre>
  
  <p>The procedure, which functions correctly when run in workbench:</p>
  
  <pre><code>CREATE DEFINER=`rjeadmin`@`%` PROCEDURE `qbpayments`(in invId int, in paydate Date, in amount decimal, in acc int, in qbid int)
  BEGIN
  
  set @invoicenumber = (select `Invoice Number` from tbldebtorinvoices where qbid = invId);
  set @currId = (select curr_id from tbldebtorinvoices where qbid = invId);
  set @entityId = (select EntityID from tbldebtorinvoices where qbid = invId);
  
  insert into tbldebtorinvoicepayments(InvoiceNumber, PaymentDate, PaymentAmount, curr_id, BankAccountID, EntityID, debtorPaymentExRate, qbid)
  values(@invoicenumber, paydate, amount, @currId, @entityId, acc, 1, qbid);
  
  select max(`Invoice Number`) from tbldebtorinvoices;
  
  END
  </code></pre>
  
  <p>My initial thought was that it may have something to do with the async/await, however it fails regardless. Also, if I remove the '?'s, the function throws the expected "expected x arguments", so it is recognising the procedure itself. Some arbitrary parameter limit??</p>