Skip to content

Instantly share code, notes, and snippets.

@krisrice
Last active February 16, 2019 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisrice/13379310b86ac9127d75535c96d6a7dc to your computer and use it in GitHub Desktop.
Save krisrice/13379310b86ac9127d75535c96d6a7dc to your computer and use it in GitHub Desktop.
var request = require('request'),fs = require('fs'),colors = require('colors');
var url = "http://KLRICE:klrice@localhost:9090/ords/klrice/_/sql"
// loop args 0="node" 1="compile" 2...= files to send
for (var i = 2; i < process.argv.length; i++) {
fs.createReadStream(process.argv[i]).pipe(request.post({
url : url,
proxy:'',
method: 'POST',
time:true,
headers : {"Content-Type":"application/sql"},
}, results))
}
function results(error,response,body){
console.log("Elapsed time:"+response.elapsedTime + "ms")
JSON.parse(body).items.forEach(function (e){
console.log( e.statementType.bold +">>"+ e.statementText.substring(0,50).replace(/\n/g," ")+"..." )
e.response.forEach(function(val,index,array){
var hasError = /^(ERROR|PLS-|PLW-|ORA-|invalid)/.test(val);
console.log( (hasError?val.red:val) )
})
})
}
/*
VSCode Task
{
"version": "2.0.0",
"tasks": [
{
"label": "compile to ORDS-SQL",
"type": "shell",
"command": "node /Users/klrice/sql/compile ${file}",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment