Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('210.1 Attribute names with embedded "$", "#", "&" and spaces', async () => {
try {
const query = `SELECT * FROM ${TABLE}`;
const opts = { outFormat: oracledb.OBJECT };
const result = await conn.execute(query, [], opts );
should.strictEqual(result.rows[0].C1.NUMBER$$VALUE, 123);
should.strictEqual(result.rows[0].C1['NUMBER##VALUE'], 456);
should.strictEqual(result.rows[0].C1['hi &coder'], 'node-oracledb');
} catch (err) {
should.not.exist(err);
}
}); // 210.1
});
return new Promise(async (resolve, reject) => {
let conn;
opts.outFormat = oracledb.OBJECT;
opts.autoCommit = true;
try {
conn = await oracledb.getConnection();
const result = await conn.execute(statement, binds, opts);
resolve(result);
} catch (err) {
reject(err);
} finally {
if (conn) { // conn assignment worked, need to close
try {
await conn.close();
} catch (err) {
console.log(err);
if (err) {
// Error connecting to DB
res.set('Content-Type', 'application/json').status(500).send(JSON.stringify({
status: 500,
message: "Error connecting to DB",
detailed_message: err.message
}));
return;
}
connection.execute("INSERT INTO user_profiles VALUES " +
"(:USER_NAME, :DISPLAY_NAME, :DESCRIPTION, :GENDER," +
":AGE, :COUNTRY, :THEME) ", [req.body.USER_NAME, req.body.DISPLAY_NAME,
req.body.DESCRIPTION, req.body.GENDER, req.body.AGE, req.body.COUNTRY,
req.body.THEME], {
autoCommit: true,
outFormat: oracledb.OBJECT // Return the result as Object
},
function (err, result) {
if (err) {
// Error
res.set('Content-Type', 'application/json');
res.status(400).send(JSON.stringify({
status: 400,
message: err.message.indexOf("ORA-00001") > -1 ? "User already exists" : "Input Error",
detailed_message: err.message
}));
} else {
// Successfully created the resource
res.status(201).set('Location', '/user_profiles/' + req.body.USER_NAME).end();
}
// Release the connection
connection.release(
return bob.save().then(function () {
return db.query('select * from people', {}, {formatRows: false, outFormat: oracledb.OBJECT}).then(function (rows) {
expect(rows).to.eql([
{
ID: bob.id,
NAME: 'bob',
PHOTO: null,
ADDRESS_ID: null
},
]);
});
});
});
if (err) {
console.error("estourou aqui: ", err);
return;
}
connection.execute("ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ',.'");
var session = connection.execute(
"ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ',.'"
);
var query = connection.execute(
products,
{},
{
outFormat: oracledb.OBJECT,
maxRows: 1000
}
);
promise
.join(session, query)
.spread(function(sessions, result) {
const index = {
title: "Send Reports Email",
products: result.rows
};
require("./send/product")(index);
return connection.close();
})
function (err, connection) {
if (err) {
cb(err);
return;
}
connection.execute(
'select dinosaur_id as "dinosaurId", ' +
' species_name as "speciesName" ' +
'from dd_dinosaurs ' +
'order by species_name',
{},//no binds
{
outFormat: oracledb.OBJECT
},
function (err, results) {
connection.close(function (err) {
if (err) {
console.error(err.message);
}
});
if (err) {
cb(err);
return;
}
cb(null, results.rows);
}
function (err, connection) {
if (err) {
cb(err);
return;
}
connection.execute(
'select location_id as "locationId", ' +
' location_name as "locationName" ' +
'from dd_locations ' +
'order by location_name',
{},//no binds
{
outFormat: oracledb.OBJECT
},
function (err, results) {
connection.close(function (err) {
if (err) {
console.error(err.message);
}
});
if (err) {
cb(err);
return;
}
cb(null, results.rows);
}
' location_name as "locationName", ' +
' city as "city", ' +
' state as "state", ' +
' postal_code as "postalCode", ' +
' country as "country", ' +
' species_name as "speciesName", ' +
' dbms_lob.substr(about_yourself, 4000) as "aboutYourself" ' +
'FROM dd_members mem ' +
'JOIN dd_locations loc ' +
' ON mem.location_id = loc.location_id ' +
'JOIN dd_dinosaurs din ' +
' ON mem.dinosaur_id = din.dinosaur_id ' +
whereClause,
binds,
{
outFormat: oracledb.OBJECT
},
function (err, results) {
connection.close(function (err) {
if (err) {
console.error(err.message);
}
});
if (err) {
callback(err);
return;
}
callback(null, results.rows[0]);
}
function (err, connection) {
if (err) {
console.log('Oracle default connection error: ' + data.database + err);
setresult({result: 0, msg: 'Connection Error: ' + err});
return console.error('Connection Error: ', err);
}
console.log('Connected to ' + data.database + ' getting table names');
var theQuery = 'SELECT user as table_schema, table_name as name FROM user_tables';
connection.execute(theQuery, [], {outFormat: oracledb.OBJECT}, function (err, result) {
if (err) { console.error(err.message); }
setresult({result: 1, items: result.rows});
connection.release(function (err) {
if (err) { console.error(err.message); }
});
});
});
};
var config = require('../config');
var oracledb = require('oracledb');
oracledb.outFormat = oracledb.OBJECT;
oracledb.autoCommit = true;
oracledb.poolMax = 4;
oracledb.maxRows = 10000;
var credentials = {
user: config.username,
password: config.password,
connectString: config.database,
};
Date.prototype.addHours= function(h) {
this.setHours(this.getHours()+h);
return this;
}
var pool;