Skip to content

Instantly share code, notes, and snippets.

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() {
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
@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
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");
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
<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
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"');
#
# Print current instances for autonomous db
# Uses $OCI_TENANCY for compartment id since that is the "root"
#
cat > db.jq <<EOF
.data[] |
."db-name" + "\tocid:" + .id ,
"\t" + ."db-name" + "_low" ,
"\tORDS Version: " + ."apex-details"."ords-version",
"\tAPEX Version: " + ."apex-details"."apex-version",
body{font-family: Hack,Slack-Lato,appleLogo,sans-serif;}
DECLARE
l_roles owa.vc_arr;
l_patterns owa.vc_arr;
l_modules owa.vc_arr;
BEGIN
l_roles(1) := 'SQL Developer';
l_patterns(1):= '/dba/*';
l_modules(1) := 'dba/awr';