0

I made this code where it inserts a new record on command. All the values are working, as shown by the following error:

code: 'ER_WARN_DATA_OUT_OF_RANGE',
  errno: 1264,
  sqlMessage: "Out of range value for column 'vehicleModel' at row 1",
  sqlState: '22003',
  index: 0,
  sql: "INSERT INTO vehicles (vehicleType, vehicleModel, vehicleOwner, vehicleSpawnX, vehicleSpawnY, vehicleSpawnZ) VALUES ('players', 2891838741, 159, -620.276123046875, -1254.2381591796875, 11.566247940063477)"

In the last line, all the values are as expected. Here's the main part of the code:

else {
        con.query("SELECT playerID FROM players WHERE scID = ?", [socialID], function (err, result) {
            playerID = result[0].playerID
            con.query("INSERT INTO vehicles (vehicleType, vehicleModel, vehicleOwner, vehicleSpawnX, vehicleSpawnY, vehicleSpawnZ) VALUES (?, ?, ?, ?, ?, ?)", ["players", vehicleModel, playerID, pos.x, pos.y, pos.z] , function (err, result) {
                if (err) {
                    console.log(err)
                }

The problem is in the second column, vehicleModel, while trying to insert 2891838741. All columns are INT except for vehicleType, that's a VARCHAR(10). I'm using MySQL Workbench 8.0 and JavaScript. I've tried switching the orders of the colums, but it didn't work.

Thanks.

Shadow
  • 32,277
  • 10
  • 49
  • 61
  • your value 2891838741 is bigger than the maximum value allowed for `int`, try using `bigint` instead. https://docs.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql?view=sql-server-ver15 – Mohammed Sep 06 '20 at 14:19

0 Answers0