Skip to content

Instantly share code, notes, and snippets.

View cmd-status.sql
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() {
View beer-status.sql
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() {
View Dockerfile
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
View awr_report_via_ords.sql
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';
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 gist:c6a8e01760adfda76c2f11c42574b276
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");
View clob2file.sql
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
View cloudshell_sqlcl.sh
#
# 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",
View ords_pool_status.html
<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/',
View title_change.sql
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"');