Last active
February 16, 2019 20:50
-
-
Save krisrice/13379310b86ac9127d75535c96d6a7dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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