I'm using version 0.0.19 and I'm trying to insert the contents of file into a blob column. I use fs.readFileSync to read the contents of the file into a buffer. The file contains binary data, not text, so I don't pass an encoding to readFileSync and it returns a buffer object.
var stmt = conn.prepareSync('insert into mytab(x1, x2) VALUES (?, ?)');
var result = stmt.executeSync(['data', fs.readFileSync(__dirname + '/x.data')]);
result.closeSync();
I catch this error object:
{
"errors": [],
"error": "[node-odbc] Error in ODBCStatement::ExecuteSync",
"message": "[IBM][CLI Driver] CLI0100E Wrong number of parameters. SQLSTATE=07001",
"state": "07001"
}
I know that "Wrong number of parameters" can also mean "Wrong type of parameters", so I think executeSync doesn't support my use of a buffer for the blob's data.
What is the correct way to insert a blob from a file?