first create a nvarchar2(200) field named 'test2' in the table "DEMO_CUSTOMERS"
insert a record to the table with the value '中国' of the field
read the record and find test2's value is '?????'
code:
var settings = require('./config');
var ora = require('strong-oracle')(settings);
var sql = 'SELECT * FROM DEMO_CUSTOMERS WHERE CUST_FIRST_NAME=:1';
var sql_insert = 'insert into DEMO_CUSTOMERS (CUST_FIRST_NAME,CUST_LAST_NAME,TEST2) values(:1,:2,:3)';
ora.createConnectionPool(settings, function(err, pool) {
if(err) {
console.error(err);
return;
}
console.log(pool.getInfo());
pool.getConnection(function(err, conn) {
conn.setAutoCommit(false);
console.log(pool.getInfo());
//console.log(sql);
conn.executeSync(sql_insert, ['firstname','lastname','中国']);
conn.execute(sql, ['firstname'],function(err, results) {
if ( err ) { console.log(err) } else {
if(results[0])
{
console.log(results[0]['TEST2']);
}
}
// results.updateCount = 1
// results.returnParam = the id of the person just inserted
conn.close(); // call this when you are done with the connection
});
});
});
save chinese to oracle error!
method:
code: