Skip to content

Instantly share code, notes, and snippets.

View tree.js
var tree = (function(){
var tab= ' ';
function ddlnode( x, inputLine, parent ) {
this.x = x;
this.y = function() {
if( this.children.length == 0 )
return this.x+1;
else
return this.children[this.children.length-1].y();
};
View loadEmojis.sql
drop table emoji;
create table emoji ( keyword varchar2(30), emoji varchar2(200));
script
// read text content from the given URL
function readText(url) {
// Using JavaImporter to resolve classes
// from specified java packages within the
// 'with' statement below
with (new JavaImporter(java.io, java.net)) {
View JmeterAPEXPOSTProcessor.js
// grab the results of the page
var PAGE = prev == null ? null : prev.getResponseDataAsString();
// debug
OUT.println('PRE PROCESSING...');
function put(id){
vars.put(id, getValue(PAGE,id,''));
}
// simple function to grab the value from the page or return the default x
function getValue(page,id,v){
View exportDDL.sql
script
var CopyOption = Java.type("java.nio.file.StandardCopyOption");
// put all files here >>>
var ddlPath = java.nio.file.FileSystems.getDefault().getPath('ddl')
var fs = java.nio.file.FileSystems.getDefault();
var f = java.nio.file.Files;
if ( ! f.exists(ddlPath)) {
f.createDirectory(ddlPath)
View bgWithReturn.js
// declare the 2 java files needed
var DriverManager = Java.type("java.sql.DriverManager");
var ScriptExecutor = Java.type("oracle.dbtools.raptor.newscriptrunner.ScriptExecutor");
var BufferedOutputStream = Java.type("java.io.BufferedOutputStream")
var ByteArrayOutputStream = Java.type("java.io.ByteArrayOutputStream")
var String = Java.type("java.lang.String")
var BGsql="";
for(var i=1;i<args.length;i++){
BGsql = BGsql + " " + args[i];
View bg.js
// declare the 2 java files needed
var DriverManager = Java.type("java.sql.DriverManager");
var ScriptExecutor = Java.type("oracle.dbtools.raptor.newscriptrunner.ScriptExecutor");
// piece the args back together minus the bg command
var BGsql="";
for(var i=1;i<args.length;i++){
BGsql = BGsql + " " + args[i];
}
View sqlcl-Dockerfile
FROM ubuntu:latest
# Install Java.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update && \
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
View sqlcl_http_server.js
var Thread = java.lang.Thread;
var ServerSocket = java.net.ServerSocket;
var PrintWriter = java.io.PrintWriter;
var InputStreamReader = java.io.InputStreamReader;
var BufferedReader = java.io.BufferedReader;
var FileInputStream = java.io.FileInputStream;
var ByteArray = Java.type("byte[]");
var PORT = 8080;
View nashorn_javascript_http_client.sql
script
//
// AS A SQLcl SCRIPT
//
var json = {"INPUT": "hello world"};
var reply = httpPost("HTTP://API.SHOUTCLOUD.IO/V1/SHOUT", JSON.stringify(json));
ctx.write("\n\n");
ctx.write(JSON.stringify(reply));
ctx.write("\n\n");
View blobs-helper.js
load('helpers.js');
/*
CREATE TABLE K
( PATH VARCHAR2(2000),
BLOB_CONTENT BLOB,
mime varchar2(40),
WHEN TIMESTAMP (6)
)
*/
/* File name */