Simple Insert leads to SQLSTATE: 22504 Native Error Code: -191 Mixed data or UTF-8 data not properly formed.

Issue #18 resolved
Kerim Gueney created an issue

I'm trying to do a fairly simlpe insert query but when executing the prepared statement, I receive:

SQLSTATE: 22504 Native Error Code: -191 Mixed data or UTF-8 data not properly formed.

I can't figure out how to fix this, my code is:

var sqlInsert = "INSERT INTO MY.PERSONS (LASTNAME, FIRSTNAME, ADDRESS, CITY) VALUES (?, ?, ?, ?) WITH NONE";

stmt.prepare(sqlInsert, function () {
    stmt.bindParam([

            ['a', db.SQL_PARAM_INPUT,1],

            ['b', db.SQL_PARAM_INPUT, 1],

            ['c', db.SQL_PARAM_INPUT, 1],

            ['d', db.SQL_PARAM_INPUT, 1],



        ], function () {
            stmt.execute();
        }

}

Any help would be appreciated

Comments (4)

  1. Musse

    Within the Bind Param Array instead of "db.SQL_PARAM_INPUT" simply replace it with "1". This 1 value will recognize that it is an input parameter.

  2. Musse

    @KerimG I was trying to debug why the constants don't work (anymore). My question is what do you require for the var db. Here is what I suggest.

    var db = require('idb-connector')
    

    The Constant should work now if you call

    db.SQL_PARAM_INPUT
    
  3. Log in to comment