Reputation: 56
today i wanna try insert data to my oracle database but the data can't saved to database here my code
async function db () {
return new Promise( async (resolve, reject) => {
try {
console.log("processing")
connection = await oracle.getConnection(konek);
var result = await connection.execute(`INSERT INTO MS_PERANGKAT (SERIALNUMBER, SSID) VALUES (:1, :2)`, ['12333', 'Rupadana']);
connection = connection.execute("SELECT * FROM ms_perangkat");
resolve(connection)
} catch (err) {
reject(err)
} finally {
if (connection) {
try {
await connection.close();
} catch(err) {
reject(err)
}
}
}
})
}
db().then( async connection => {
console.log(connection)
}).catch(err => {
console.log('Error: ',err)
});
Here the output :
{
metaData: [ { name: 'SERIALNUMBER' }, { name: 'SSID' } ],
rows: [ [ '12333', 'Rupadana' ] ]
}
Upvotes: 1
Views: 1024
Reputation: 56
that happens because the query hasn't been committed
here the code:
var result = await connection.execute(`INSERT INTO MS_PERANGKAT (SERIALNUMBER, SSID) VALUES (:1, :2)`, ['12333', 'Rupadana'],{autoCommit: true});
Upvotes: 1