Skip to content

Instantly share code, notes, and snippets.

@joshholl
Created March 18, 2017 03:38
Show Gist options
  • Save joshholl/d70ce07cea15983f2987d596d8f489ce to your computer and use it in GitHub Desktop.
Save joshholl/d70ce07cea15983f2987d596d8f489ce to your computer and use it in GitHub Desktop.
SQL and test file to trigger a numeric overflow error from oracledb compiled on windows
var oracledb = require('oracledb');
//replace connectString as appropriate
var connectionInfo = {
user: 'nodetest',
password: 'nodetest',
connectString: ""
}
//arbitrarily large to help trigger this
var runs = 400;
let runIt = (theNumber) => oracledb.getConnection(connectionInfo,
function(error, connection) {
if (error) return;
else {
var sql = 'BEGIN testNumericOutBinds(:numberIn, :numberOut); END;'
var params = {
numberIn: theNumber,
numberOut: {
type: oracledb.NUMBER,
dir: oracledb.BIND_OUT
}
}
connection.execute(sql, params, function(err, result) {
if (err) {
console.log('tried number ' + theNumber, err)
}
console.log(result);
connection.close(function(err, a){})
});
}
});
for(var theNumber = 0; theNumber < runs; theNumber++) {
runIt(theNumber);
}
CREATE USER nodetest IDENTIFIED BY nodetest;
GRANT connect to nodetest;
grant create session to nodetest;
grant create procedure to nodetest;
create or replace PROCEDURE nodetest.testNumericOutBinds(
theInFile NUMBER,
theOutVal OUT NUMBER
) AS
BEGIN
theOutVal := theInFile;
END;
/
grant execute on nodetest.testNumericOutBinds to nodetest;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment