Skip to content

Instantly share code, notes, and snippets.

script
var dbUser = util.executeReturnOneCol('select user from dual');
var globalName = util.executeReturnOneCol('select global_name from global_name');
var title = "sqlcl " +dbUser + "@" + globalName
sqlcl.setStmt('!echo -ne "\033]0;'+title+'\007"');
<html>
<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hack-font@3/build/web/hack-subset.css">
<script>
var refreshInteval;
function poolListing(){
// populate the list of pools
fetch('http://localhost:8080/ords/_/instance-api/stable/database-pools-cache/',
script
// issue the sql
var binds = {}
var ret = util.executeReturnList('select help_text,page_name from APEX_APPLICATION_PAGES where rownum=1 and help_text is not null',binds);
// loop the results
for (i = 0; i < ret.length; i++) {
// debug is nice
ctx.write( ret[i].PATH+ "\n");
// get the CLOB stream
var OCIProfiles = Java.type("oracle.dbtools.oci.OCIProfiles");
var OCIRESTClient = Java.type("oracle.dbtools.oci.OCIRESTClient");
var OCIRequest = Java.type("oracle.dbtools.oci.OCIRequest");
var Instant = Java.type("java.time.Instant");
var DateTimeFormatter = Java.type("java.time.format.DateTimeFormatter");
var TemporalAccessor = Java.type("java.time.temporal.TemporalAccessor");
var FileUtils = Java.type("oracle.dbtools.common.utils.FileUtils");
var StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
var Files = Java.type("java.nio.file.Files");
var Paths = Java.type("java.nio.file.Paths");
@krisrice
krisrice / sqlcl.sh
Last active September 1, 2023 12:59
sql() {
# REMOTE source this script
#
# . <(curl -s https://gist.githubusercontent.com/krisrice/fec43fd9f53e4286e5cc360b554e3c0f/raw/62ec382d7511c7cc44703a9a2f75a4a7f233efe2/sqlcl.sh)
# Set the stage directory
STAGE_DIR=/tmp
# Check whether internet connection exists
if ping -c 1 -t 3 download.oracle.com > /dev/null; then
from oraclelinux:8
run yum-config-manager --add-repo=http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64
run yum -y install ords
set scan off
set define off
script
var StatusBarComponent = Java.type("oracle.dbtools.raptor.console.StatusBarComponent");
var component = new StatusBarComponent() {
getName: function() {
return "beer";
},
getDescription: function() {
set scan off
set define off
script
var StatusBarComponent = Java.type("oracle.dbtools.raptor.console.StatusBarComponent");
var component = new StatusBarComponent() {
getName: function() {
return "cmdstatus";
},
getDescription: function() {
set scan off
set define off
script sqlid.js
set statusbar add sqlid
with colors as (
select 'black' value from dual
union all
select 'green' from dual
union all
select 'yellow' from dual
union all
select 'blue' from dual
union all
select 'magenta' from dual