var oracledb = require('oracledb');
oracledb.getConnection(
{
user: 'c##root',
password: 'root',
connectString: 'localhost:1521/orcl'
},
function (err, connection) {
if (err) {
console.log('error while connect to OracleDB :' + err.stack);
return;
} else {
console.log("Database connected")
connection.execute("INSERT INTO person (name) VALUES ( :NAME) ", ['DOE'], function (err, result) {
if (err) {
console.error(err);
return;
} else {
console.log("Value sucessfully added to database: " + "'database name here'")
}
});
}
});
我想在每次执行特定查询时获取数据库的名称。
答案 0 :(得分:0)
请参阅How to find Oracle Service Name
select sys_context('userenv','service_name') from dual;
给定代码中的PS,orcl
是服务名称,而不是SID。