0

I have this:

var userRegister2 = "INSERT INTO GOT (USERNAME, PASSWORD, NAME, USERID) VALUES (?)";
ibmdb.open(ibmdbconnMaster, function (err, conn) {
  if (err) return console.log(err);
  conn.query(userRegister2, [registerDetails.username, registerDetails.password, registerDetails.name, registerDetails.userid], function (err, rows) {
    if (err) {
      console.log(err);
    }

    console.log("success!")


    res.render('index.ejs')

    conn.close(function () {
    });
  });
});

all looks good to me, but then what happens is I get this error:

 SQL0117N  The number of values assigned is not the same as the number of specified or implied columns or variables.

In my database table, I have only those 4 columns, so I am not sure what else to do?

3
  • You need to have the same number of parameter-markers as parameters, i.e values(?,?,?,?) Commented Apr 8, 2022 at 15:53
  • Try "INSERT INTO GOT (USERNAME, PASSWORD, NAME, USERID) VALUES ?" Commented Apr 8, 2022 at 15:57
  • @mao lol can't believe I missed that. Thank you so much! Commented Apr 8, 2022 at 16:06

1 Answer 1

1

The solution is to change the code so that the number of parameter-markers matches the number of parameters.

In your case, that means VALUES (?,?,?,?) because you are supplying four parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.