Is any other way to get database name other than executing query
Gopi, July 07, 2016 - 5:42 pm UTC
In my case i creating API for query execution. I want to show database name for corresponding query when each time query execute. I don't wan't to execute one more query for database name. And also i don't want to change the original query to get database name. My question is there is any other way to get database name like using connection object or using result after query execution.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 {
<b>console.log("Value sucessfully added to database: " + "'database name
here'")</b>
}
});
}
});
In above example i want to show database name in console (where highlighted bold) without one more query and without change the above query.
Thanks
July 09, 2016 - 1:48 am UTC
I got this from Dan McGhan who works on the driver.
"This can be done easily today by adding properties to the connection when created or retrieved from a pool"
If that is not enough info, let me know and I'll ask for a clarification.
Cheers,
Connor
Without query execution like select sys.database_name from dual, how to get database name .
Gopi, July 09, 2016 - 8:44 am UTC
Is there any way to get database name other than executing query like select sys.database_name from dual.
Can i get database name using connection object .
connection.getDatabaseName()
(Or)
Using result after executing any database query
result.getDatabaseName()
If any one know solution please describe with example for better understanding.
Thanks.
problem solved.
gopi, July 12, 2016 - 10:14 am UTC
problem solved by adding property to the connection object.
Thanks
July 12, 2016 - 10:35 am UTC
Glad you solved it.