0

如何在 oracle db node js 中获取数据库名称


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'")
                }
            });
        }
    });

我想在每次执行特定查询时获取数据库的名称。

4

1 回答 1

0

请参阅如何查找 Oracle 服务名称

select sys_context('userenv','service_name') from dual;

给定代码中的 PSorcl是服务名称,而不是 SID。

于 2016-07-07T02:15:08.173 回答