├── LICENSE.txt ├── README.md ├── SECURITY.md ├── devops ├── Pipelines │ ├── README.md │ └── examples │ │ ├── jenkensfile │ │ ├── jenkinsfile2 │ │ └── spinnaker.json ├── README.md ├── cicd │ ├── README.md │ ├── cicd_db_template │ │ ├── Jenkinsfile │ │ ├── README.md │ │ ├── apps │ │ │ ├── f101.xml │ │ │ └── f101 │ │ │ │ └── lb_files_here │ │ ├── database │ │ │ ├── controller.xml │ │ │ ├── functions │ │ │ │ └── lb_files_here │ │ │ └── tables │ │ │ │ └── lb_files_here │ │ ├── etc │ │ │ ├── mainsetup │ │ │ │ └── mainsetup_files_here │ │ │ ├── postsetup │ │ │ │ └── postsetup_files_here │ │ │ └── presetup │ │ │ │ └── presetup_files_here │ │ ├── static │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── html │ │ │ │ └── main.html │ │ │ ├── images │ │ │ │ └── main.jpg │ │ │ └── js │ │ │ │ └── main.js │ │ ├── ut │ │ │ ├── main.ut │ │ │ └── utPLSQL │ │ │ │ └── utplsql.sql │ │ └── version.txt │ └── sample_nodeJS_DB_app │ │ ├── README.md │ │ ├── database │ │ ├── controller.xml │ │ ├── functions │ │ │ └── lb_files_here │ │ └── tables │ │ │ └── lb_files_here │ │ ├── docker │ │ ├── .dockerignore │ │ └── Dockerfile │ │ ├── etc │ │ ├── mainsetup │ │ │ └── mainsetup_files_here │ │ ├── postsetup │ │ │ └── postsetup_files_here │ │ └── presetup │ │ │ └── presetup_files_here │ │ ├── node-app │ │ ├── index.js │ │ └── package.json │ │ ├── static │ │ ├── css │ │ │ └── main.css │ │ ├── html │ │ │ └── main.html │ │ ├── images │ │ │ └── main.jpg │ │ └── js │ │ │ └── main.js │ │ ├── ut │ │ ├── main.ut │ │ └── utPLSQL │ │ │ └── utplsql.sql │ │ └── version.txt └── terraform │ ├── ADB-Vanity-ORM │ ├── README.md │ ├── Variables.tf │ └── main.tf │ ├── ADB-Vanity-URL-without-customer-managed-ORDS-plus │ ├── README.md │ ├── Variables.tf │ └── main.tf │ ├── ADB-Vanity-URL-without-customer-managed-ORDS │ ├── README.md │ ├── Variables.tf │ └── main.tf │ ├── Jenkins │ └── README.md │ ├── ORDS_dbcs │ ├── README.md │ ├── main.tf │ ├── ords_params.properties │ └── variables.tf │ ├── VanityURL-ADB-PE │ ├── README.md │ ├── Variables.tf │ ├── completeSetupFullVM_PE.tf │ └── main.tf │ ├── VanityURL-ResourceManager.zip │ ├── VanityURL-ResourceManager │ ├── README.md │ ├── Variables.tf │ ├── main.tf │ └── schema.yaml │ ├── vanityURL-ADB │ ├── README.md │ ├── Variables.tf │ ├── completeSetupFullVM.tf │ ├── completeSetupMicroVM.tf │ └── ords_conf.zip │ └── vanityURL-DBCS │ ├── README.md │ ├── Variables.tf │ ├── images │ └── hover.png │ ├── main.tf │ ├── ords_params.properties │ └── standalone.properties.SSL ├── examples ├── README.md ├── oci-db-tools-service │ ├── Java │ │ └── Java Sample.md │ └── Python │ │ ├── DBToolsTest.py │ │ └── Python Sample.md ├── oci │ ├── bastion-dbcs.md │ ├── files │ │ ├── group.json │ │ └── serv.json │ ├── images │ │ ├── bast-1.png │ │ ├── bast-2.png │ │ ├── bast-3.png │ │ ├── bast-4.png │ │ ├── bast-5.png │ │ ├── bast-6.png │ │ ├── bast-7.png │ │ └── bast-8.png │ └── ords-oci-logging.md └── rest │ ├── README.md │ └── xcode-iOS │ ├── README.md │ ├── ords_iPhone │ ├── ords_iPhone.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcuserdata │ │ │ │ └── bspendol.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── bspendol.xcuserdatad │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── ords_iPhone │ │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── ContentView.swift │ │ ├── EmpDetail.swift │ │ ├── Info.plist │ │ ├── Preview Content │ │ └── Preview Assets.xcassets │ │ │ └── Contents.json │ │ └── ords_iPhoneApp.swift │ └── setups │ └── emps.sql ├── ords ├── Parameters │ ├── Example2.md │ ├── Example3.md │ ├── Example4.md │ ├── READme.md │ ├── parameter-header-response.png │ ├── parameter-name-bind.png │ ├── parameters_rest.sql │ ├── parameters_table.sql │ ├── rest-tree.png │ ├── uri-parameters.png │ └── url-parameter.png ├── READme.md ├── oow19_lab │ └── ORDS_SQLWeb │ │ └── html │ │ ├── ORDS_SQLWeb.html │ │ ├── css │ │ ├── font-awesome.min.css │ │ ├── normalize.min.css │ │ └── obe-lite.css │ │ ├── files │ │ ├── inline-code-example.txt │ │ ├── sample-arch-image.txt │ │ └── sample-image-1.txt │ │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ │ ├── img │ │ ├── 1.1.png │ │ ├── 1.10.png │ │ ├── 1.11.png │ │ ├── 1.12.png │ │ ├── 1.13.png │ │ ├── 1.14.png │ │ ├── 1.15.png │ │ ├── 1.16.png │ │ ├── 1.17.png │ │ ├── 1.18.png │ │ ├── 1.19.png │ │ ├── 1.2.png │ │ ├── 1.20.png │ │ ├── 1.21.png │ │ ├── 1.22.png │ │ ├── 1.23.png │ │ ├── 1.24.png │ │ ├── 1.25.png │ │ ├── 1.26.png │ │ ├── 1.27.png │ │ ├── 1.28.png │ │ ├── 1.29.png │ │ ├── 1.3.png │ │ ├── 1.30.png │ │ ├── 1.31.png │ │ ├── 1.32.png │ │ ├── 1.4.png │ │ ├── 1.5.png │ │ ├── 1.6.png │ │ ├── 1.7.png │ │ ├── 1.8.png │ │ ├── 1.9.png │ │ ├── 32_1.png │ │ ├── 32_2.png │ │ ├── 32_3.png │ │ ├── 32_4.png │ │ ├── 32_5.png │ │ ├── 32_6.png │ │ ├── 32_7.png │ │ ├── 32_8.png │ │ ├── 32_begin.png │ │ ├── 32_more.png │ │ ├── 32_next.png │ │ ├── obe_tag.png │ │ ├── oracle_doc_logo.png │ │ ├── sample-arch-image.png │ │ └── sample-image-1.png │ │ └── js │ │ ├── jquery-1.11.0.min.js │ │ ├── jquery-ui-1.10.4.custom.js │ │ ├── jquery.tocify.jd.js │ │ └── leftnav.js ├── rest-sql │ ├── curl-2-sqls.sh │ ├── curl-binds.sh │ ├── curl-ddl.sh │ ├── curl-dual.sh │ ├── curl-pagination.sh │ ├── curl-restricted-cmds.sh │ ├── curl-script.sh │ └── demo-all-in-one.html └── swagger.png ├── sbom_generation.yaml └── sqlcl ├── EDIT.md ├── FORMATTING.md ├── README.md ├── SCRIPTING.md ├── datamove-schema ├── datamove.sql ├── dpexp.sql ├── dpimp.sql ├── dpxfer.sql ├── example.log ├── postcheck.sql ├── precheck.sql ├── readme.md ├── setup.sql └── teardown.sql ├── examples ├── SetSchema.js ├── apx.js ├── apxexp.js ├── apximp.js ├── args.js ├── audio.js ├── autocorrect.js ├── bg.js ├── blob.helper.all.js ├── blob.js ├── blob2file.sql ├── card.js ├── card.sql ├── cat.js ├── color.sql ├── compressedBlob.js ├── customAccept.sql ├── customCommand.js ├── emojiWorldData.sql ├── exec.js ├── jython_example.sh ├── kill.js ├── lib │ └── helpers.js ├── longops.js ├── numbers.sql ├── printtab.js ├── reserved.js ├── rspool.js ├── snark.js ├── sql.ecma6.js ├── sql.js ├── sqlprompt.js ├── stats.js └── sync.js ├── images ├── csv.png ├── inline1.png ├── inline2.png ├── sql-command-line-200.png └── traffic_light.png ├── java ├── .classpath ├── .gitignore ├── .project ├── README.md ├── myfile.sql ├── sqlcl-eclipse-path.png └── src │ ├── ParseScriptRunOneAtATime.java │ └── RunMyScript.java └── sql-command-line-200.png /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, 2023 Oracle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools 2 | This project is a repository of tools and sample code that will demonstrate various concepts to assist developers in building applications around 3 | Oracle Database technologies. 4 | 5 | SDKs and scripts will be available to integrate with [SQL Developer][1], [Data Modeler][2], [Oracle REST Data Services][3] and [DBaaS][4]. 6 | 7 | ## Contributing 8 | 9 | This project is not accepting external contributions at this time. For bugs or enhancement requests, please file a GitHub issue unless it’s security related. When filing a bug remember that the better written the bug is, the more likely it is to be fixed. If you think you’ve found a security vulnerability, do not raise a GitHub issue and follow the instructions in our [security policy](./SECURITY.md). 10 | 11 | ## Security 12 | 13 | Please consult the [security guide](./SECURITY.md) for our responsible security vulnerability disclosure process 14 | 15 | ## License 16 | 17 | Copyright (c) 2015, 2023 Oracle and/or its affiliates. 18 | 19 | Released under the MIT license. 20 | 21 | [1]: http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html 22 | [2]: http://www.oracle.com/technetwork/developer-tools/datamodeler/overview/index.html 23 | [3]: http://www.oracle.com/technetwork/developer-tools/rest-data-services/overview/index.html 24 | [4]: https://cloud.oracle.com/database 25 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /devops/Pipelines/README.md: -------------------------------------------------------------------------------- 1 | # Pipeline Code for Oracle Database/APEX CICD 2 | 3 | These folders have pipeline code for CICD processes. Code here will constantly be changing and added as we develop more and more methods and refine them. -------------------------------------------------------------------------------- /devops/Pipelines/examples/jenkensfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage('Start') { 5 | when { 6 | expression { 7 | return env.ref != 'masterMan' 8 | } 9 | 10 | } 11 | steps { 12 | script { 13 | currentBuild.upstreamBuilds?.each { b -> 14 | echo "Upstream build: ${b.getFullDisplayName()}" 15 | } 16 | } 17 | 18 | } 19 | } 20 | 21 | stage('preparation') { 22 | steps { 23 | echo 'ORZ-000 ORA' 24 | script { 25 | def buildCause = currentBuild.getBuildCauses()[0].shortDescription 26 | echo "Current build was caused by: ${buildCause}\n" 27 | } 28 | 29 | } 30 | } 31 | 32 | stage('Some Logic') { 33 | steps { 34 | script { 35 | echo("${env.BUILD_NUMBER}") 36 | 37 | emailext(attachLog: true, body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", from: "${env.admin_email}", replyTo: "${env.admin_email}", to: "${env.admin_email}", subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") 38 | 39 | 40 | if (env.ref == 'main') { 41 | echo("if") 42 | } else { 43 | echo("else") 44 | } 45 | } 46 | 47 | } 48 | } 49 | 50 | stage('Check Logs') { 51 | steps { 52 | script { 53 | if (manager.logContains('.*ORA-.*')) { 54 | error("Build failed due to ORA Errors") 55 | } 56 | } 57 | 58 | } 59 | } 60 | 61 | stage('Archive') { 62 | steps { 63 | sh """echo BUILD_ID=${env.BUILD_NUMBER} >> ./jank.spin""" 64 | sh """echo ARTIFACT_URL=http://URL_OF_JENKINS_INSTANCE/job/jenkinsLogic/job/main/${env.BUILD_NUMBER}/artifact/ >> ./jank.spin""" 65 | sh 'zip -r build.zip . -x \'*.git*\'' 66 | archiveArtifacts '**/build.zip' 67 | archiveArtifacts '**/jank.spin' 68 | archiveArtifacts(artifacts: '**/jank.spin.deploy', allowEmptyArchive: true) 69 | } 70 | } 71 | 72 | } 73 | environment { 74 | admin_email = 'databasecicd@gmail.com' 75 | } 76 | post { 77 | unsuccessful { 78 | echo 'unsuccessful' 79 | } 80 | 81 | success { 82 | echo 'success' 83 | } 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /devops/Pipelines/examples/jenkinsfile2: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage('Start') { 5 | steps { 6 | echo 'CICD Start for ${env.BRANCH_NAME}' 7 | } 8 | } 9 | 10 | stage('terraform go!') { 11 | steps { 12 | sh '''cd ./build 13 | terraform init 14 | terraform plan 15 | terraform apply -auto-approve''' 16 | } 17 | } 18 | 19 | stage('Check Logs for ORA Errors') { 20 | steps { 21 | script { 22 | if (manager.logContains('.*ORA-[0-9]{4,5}$.*')) { 23 | error("Build failed because of an ORA Error") 24 | } 25 | } 26 | 27 | } 28 | } 29 | 30 | stage('Backup if Successful') { 31 | steps { 32 | 33 | echo 'Backing up DB' 34 | 35 | // sh '''cd ./post_build 36 | // terraform init 37 | // terraform plan 38 | // terraform apply''' 39 | } 40 | } 41 | 42 | // stage('Clean Up') { 43 | // steps { 44 | // sh '''cd ./post_setup 45 | // terraform destroy 46 | // cd ./build 47 | // terraform destroy''' 48 | // } 49 | // } 50 | 51 | } 52 | 53 | post { 54 | unsuccessful { 55 | 56 | emailext(attachLog: true, attachmentsPattern: '**/build/autonomous_database_wallet.zip', body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", from: 'databasecicd@gmail.com', replyTo: 'databasecicd@gmail.com', to: 'databasecicd@gmail.com', subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") 57 | } 58 | 59 | success { 60 | 61 | 62 | emailext(attachLog: true, body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", from: 'databasecicd@gmail.com', replyTo: 'databasecicd@gmail.com', to: 'databasecicd@gmail.com', subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") 63 | 64 | // sh '''cd ./post_setup 65 | // terraform destroy 66 | // cd ./build 67 | // terraform destroy''' 68 | 69 | sh '''cd ./build 70 | terraform destroy -auto-approve''' 71 | 72 | 73 | 74 | } 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /devops/Pipelines/examples/spinnaker.json: -------------------------------------------------------------------------------- 1 | { 2 | "expectedArtifacts": [], 3 | "keepWaitingPipelines": false, 4 | "lastModifiedBy": "anonymous", 5 | "limitConcurrent": false, 6 | "parameterConfig": [], 7 | "spelEvaluator": "v4", 8 | "stages": [ 9 | { 10 | "failPipeline": true, 11 | "instructions": "which environment", 12 | "judgmentInputs": [ 13 | { 14 | "value": "DEV" 15 | }, 16 | { 17 | "value": "UAT" 18 | }, 19 | { 20 | "value": "PROD" 21 | } 22 | ], 23 | "name": "deployment", 24 | "notifications": [], 25 | "refId": "1", 26 | "requisiteStageRefIds": [ 27 | "7" 28 | ], 29 | "stageEnabled": { 30 | "expression": "'${ branch }' == 'main'", 31 | "type": "expression" 32 | }, 33 | "type": "manualJudgment" 34 | }, 35 | { 36 | "name": "Deploy to Dev", 37 | "preconditions": [ 38 | { 39 | "context": { 40 | "expression": "${#judgment(\"deployment\") == 'DEV'}" 41 | }, 42 | "failPipeline": false, 43 | "type": "expression" 44 | } 45 | ], 46 | "refId": "2", 47 | "requisiteStageRefIds": [ 48 | "1" 49 | ], 50 | "type": "checkPreconditions" 51 | }, 52 | { 53 | "name": "Deploy to UAT", 54 | "preconditions": [ 55 | { 56 | "context": { 57 | "expression": "${#judgment(\"deployment\") == 'UAT'}" 58 | }, 59 | "failPipeline": false, 60 | "type": "expression" 61 | } 62 | ], 63 | "refId": "4", 64 | "requisiteStageRefIds": [ 65 | "1" 66 | ], 67 | "type": "checkPreconditions" 68 | }, 69 | { 70 | "name": "Deploy to Prod", 71 | "preconditions": [ 72 | { 73 | "context": { 74 | "expression": "${#judgment(\"deployment\") == 'PROD'}" 75 | }, 76 | "failPipeline": false, 77 | "type": "expression" 78 | } 79 | ], 80 | "refId": "5", 81 | "requisiteStageRefIds": [ 82 | "1" 83 | ], 84 | "type": "checkPreconditions" 85 | }, 86 | { 87 | "failOnFailedExpressions": true, 88 | "name": "Evaluate Variables", 89 | "refId": "6", 90 | "requisiteStageRefIds": [], 91 | "type": "evaluateVariables", 92 | "variables": [ 93 | { 94 | "key": "stage", 95 | "value": "${ trigger.properties['STAGE']}" 96 | }, 97 | { 98 | "key": "branch", 99 | "value": "${scmInfo.branch}" 100 | } 101 | ] 102 | }, 103 | { 104 | "name": "Check Repo Status", 105 | "preconditions": [ 106 | { 107 | "cloudProvider": "oracle", 108 | "context": { 109 | "expression": "'${ stage }' == 'PROD'", 110 | "failureMessage": "Repository is not enabled for deployment" 111 | }, 112 | "failPipeline": true, 113 | "type": "expression" 114 | } 115 | ], 116 | "refId": "7", 117 | "requisiteStageRefIds": [ 118 | "6" 119 | ], 120 | "type": "checkPreconditions" 121 | }, 122 | { 123 | "continuePipeline": false, 124 | "failPipeline": true, 125 | "job": "devDeploy", 126 | "master": "ociJenkins", 127 | "name": "JenkinsDevPipe", 128 | "parameters": {}, 129 | "refId": "8", 130 | "requisiteStageRefIds": [ 131 | "2" 132 | ], 133 | "type": "jenkins" 134 | }, 135 | { 136 | "continuePipeline": false, 137 | "failPipeline": true, 138 | "job": "devDeploy", 139 | "master": "ociJenkins", 140 | "name": "JenkinsUATPipe", 141 | "parameters": {}, 142 | "refId": "9", 143 | "requisiteStageRefIds": [ 144 | "4" 145 | ], 146 | "type": "jenkins" 147 | }, 148 | { 149 | "continuePipeline": false, 150 | "failPipeline": true, 151 | "job": "devDeploy", 152 | "master": "ociJenkins", 153 | "name": "JenkinsProdPipe", 154 | "parameters": {}, 155 | "refId": "10", 156 | "requisiteStageRefIds": [ 157 | "5" 158 | ], 159 | "type": "jenkins" 160 | } 161 | ], 162 | "triggers": [ 163 | { 164 | "enabled": true, 165 | "expectedArtifactIds": [], 166 | "job": "jenkinsLogic/job/main", 167 | "master": "ociJenkins", 168 | "propertyFile": "jank.spin", 169 | "type": "jenkins" 170 | } 171 | ], 172 | "updateTs": "1617304409240" 173 | } -------------------------------------------------------------------------------- /devops/README.md: -------------------------------------------------------------------------------- 1 | # DevOPs DB Tools Examples and Samples 2 | 3 | This set of directories will contain samples of code for CICD pipelines, Terraform scrpits for easy setup in OCI, liquibase examples as well as other CICD and DevOps related artifacts. 4 | 5 | On April 7th, 2021, we had a web conference around these topics. 6 | 7 | https://www.youtube.com/watch?v=P3La7ig37CU 8 | 9 | [![Watch the video](https://img.youtube.com/vi/P3La7ig37CU/0.jpg)](https://www.youtube.com/watch?v=P3La7ig37CU) 10 | 11 | ### Contents: 12 | 13 | #### CICD 14 | 15 | Template/Directory structure for database/APEX CICD 16 | 17 | #### Pipelines 18 | This directory contains samples of code for Jenkins and Spinnaker for DB/APEX CICD 19 | 20 | #### Terraform 21 | Here we have sample code for using terraform in OCI for the following tasks: 22 | 1. **Vanity URL with ADB**: Create a user managed ORDS instance on a compute VM for an autonomous DB and custom domain name using Let's Encrypt 23 | 2. **Vanity URL with DBCS**: Create a user managed ORDS instance on a compute VM for a DBCS instance (VM, BM or ExaCS) and custom domain name using Let's Encrypt 24 | 3. **Simple ORDS setup**: Create a VM with ORDS attached to a DBCS instance 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | #### Also, here is a lizard in a wizard outfit: 34 | 35 | ![4POfp](https://user-images.githubusercontent.com/69256666/114067567-ab08c000-9838-11eb-92d0-629615ff0b0d.jpg) 36 | -------------------------------------------------------------------------------- /devops/cicd/README.md: -------------------------------------------------------------------------------- 1 | # All things CICD -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | 3 | environment { 4 | admin_email = "databasecicd@gmail.com" 5 | } 6 | 7 | agent any 8 | stages { 9 | stage('Start') { 10 | steps { 11 | echo 'APEX and Databse CICD Start for ${env.BRANCH_NAME}' 12 | } 13 | } 14 | 15 | stage('Terraform GO!') { 16 | steps { 17 | sh '''cd ./build 18 | terraform init 19 | terraform plan 20 | terraform apply -auto-approve''' 21 | } 22 | } 23 | 24 | stage('Check Logs for ORA Errors') { 25 | steps { 26 | script { 27 | if (manager.logContains('.*ORA-[0-9]{4,5}$.*')) { 28 | error("Build failed because of an ORA Error") 29 | } 30 | } 31 | 32 | } 33 | } 34 | 35 | stage('Backup if Successful') { 36 | steps { 37 | 38 | echo 'Backing up DB' 39 | 40 | // sh '''cd ./post_build 41 | // terraform init 42 | // terraform plan 43 | // terraform apply''' 44 | } 45 | } 46 | 47 | } 48 | 49 | post { 50 | unsuccessful { 51 | 52 | emailext(attachLog: true, attachmentsPattern: '**/build/autonomous_database_wallet.zip', body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", from: '${env.admin_email}', replyTo: '${env.admin_email}', to: '${env.admin_email}', subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") 53 | } 54 | 55 | success { 56 | 57 | 58 | emailext(attachLog: true, body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", from: "${env.admin_email}", replyTo: "${env.admin_email}", to: "${env.admin_email}", subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") 59 | 60 | // sh '''cd ./post_setup 61 | // terraform destroy 62 | // cd ./build 63 | // terraform destroy''' 64 | 65 | sh '''cd ./build 66 | terraform destroy -auto-approve''' 67 | 68 | 69 | 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/README.md: -------------------------------------------------------------------------------- 1 | # Sample template/directory structure for database and APEX CICD 2 | 3 | This directory structure is a sample structure that can be used for CICD with the Oracle Database and APEX 4 | 5 | 6 | 7 | ## Directory Overview 8 | 9 | The following structure would be used as a guide. The Database directory would be populated via liquibase and SQLcl. Using the -split option, liquibase would create folders for each type of database object (table, function, procedure, etc). The APEX directory would be populated with either an export via SQLcl or liquibase. 10 | 11 | 12 | ``` 13 | Repository Top Level 14 | JenkinsFile (if using jenkins) 15 | README.md 16 | version.txt 17 | Database 18 | controler.xml 19 | Tables 20 | ... 21 | Procedures 22 | ... 23 | Functions 24 | ... 25 | Indexes 26 | ... 27 | (all db objects) 28 | APEX (or Apps) 29 | FXXX.xml 30 | FXXX 31 | ... 32 | FYYY.xml 33 | FYYY 34 | ... 35 | etc folder 36 | presetup 37 | ... 38 | postsetup 39 | ... 40 | mainsetup 41 | ... 42 | ut 43 | utPLSQL 44 | scripts 45 | ... 46 | static 47 | html 48 | ... 49 | css 50 | ... 51 | js 52 | ... 53 | images 54 | ... 55 | ``` 56 | 57 | -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/apps/f101.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/apps/f101.xml -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/apps/f101/lb_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/apps/f101/lb_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/database/controller.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/database/controller.xml -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/database/functions/lb_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/database/functions/lb_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/database/tables/lb_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/database/tables/lb_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/etc/mainsetup/mainsetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/etc/mainsetup/mainsetup_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/etc/postsetup/postsetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/etc/postsetup/postsetup_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/etc/presetup/presetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/etc/presetup/presetup_files_here -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/static/css/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/static/css/main.css -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/static/html/main.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/static/html/main.html -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/static/images/main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/static/images/main.jpg -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/static/js/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/static/js/main.js -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/ut/main.ut: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/ut/main.ut -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/ut/utPLSQL/utplsql.sql: -------------------------------------------------------------------------------- 1 | select * form emp 2 | / -------------------------------------------------------------------------------- /devops/cicd/cicd_db_template/version.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/cicd_db_template/version.txt -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/README.md: -------------------------------------------------------------------------------- 1 | # Sample template/directory structure for database and NodeJS CICD 2 | 3 | This directory structure is a sample structure that can be used for CICD with the Oracle Database and NodeJS 4 | 5 | 6 | 7 | ## Directory Overview 8 | 9 | The following structure would be used as a guide. The Database directory would be populated via liquibase and SQLcl. Using the -split option, liquibase would create folders for each type of database object (table, function, procedure, etc). The APEX directory would be populated with either an export via SQLcl or liquibase. 10 | 11 | 12 | ``` 13 | Repository Top Level 14 | README.md 15 | version.txt 16 | docker 17 | Dockerfile 18 | Database 19 | controler.xml 20 | Tables 21 | ... 22 | Procedures 23 | ... 24 | Functions 25 | ... 26 | Indexes 27 | ... 28 | (all db objects) 29 | node-app 30 | package.json 31 | index.js 32 | etc folder 33 | presetup 34 | ... 35 | postsetup 36 | ... 37 | mainsetup 38 | ... 39 | ut 40 | utPLSQL 41 | scripts 42 | ... 43 | static 44 | html 45 | ... 46 | css 47 | ... 48 | js 49 | ... 50 | images 51 | ... 52 | ``` 53 | 54 | -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/database/controller.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/database/controller.xml -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/database/functions/lb_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/database/functions/lb_files_here -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/database/tables/lb_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/database/tables/lb_files_here -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/docker/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16 2 | 3 | # Create app directory 4 | WORKDIR /usr/src/app 5 | 6 | # Install app dependencies 7 | # A wildcard is used to ensure both package.json AND package-lock.json are copied 8 | # where available ([email protected]+) 9 | COPY package*.json ./ 10 | 11 | RUN npm install 12 | RUN npm install node-fetch 13 | RUN npm install btoa 14 | # If you are building your code for production 15 | # RUN npm ci --only=production 16 | 17 | # Bundle app source 18 | COPY . . 19 | 20 | EXPOSE 8080 21 | CMD [ "node", "index.js" ] 22 | -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/etc/mainsetup/mainsetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/etc/mainsetup/mainsetup_files_here -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/etc/postsetup/postsetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/etc/postsetup/postsetup_files_here -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/etc/presetup/presetup_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/etc/presetup/presetup_files_here -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/node-app/index.js: -------------------------------------------------------------------------------- 1 | var fetch = require('node-fetch'); 2 | var btoa = require('btoa'); 3 | function runit(sql,callback){ 4 | fetch( "https://ADB-HOSTNAME/ords/nodejsapp/_/sql",{ 5 | method: "POST", 6 | headers: { 7 | "Content-Type": "application/sql", 8 | "Authorization": "Basic " + btoa("nodejsapp" + ":" +"PASSWORD") 9 | }, 10 | body: sql 11 | } ) 12 | .then(res => res.json()) 13 | .then(function(json){ 14 | callback(json); 15 | }).catch(function(e){ 16 | console.log(e); 17 | }); 18 | } 19 | runit('select * from emp',function(data) { 20 | console.log(data.items[0]); 21 | }); -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/node-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample-oracle-db-node-app", 3 | "description": "Sample OracleDB and ORDS NodeJS App", 4 | "version": "1.0.0", 5 | "private": true, 6 | "scripts": { 7 | "start": "node server.js" 8 | } 9 | } -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/static/css/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/static/css/main.css -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/static/html/main.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/static/html/main.html -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/static/images/main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/static/images/main.jpg -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/static/js/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/static/js/main.js -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/ut/main.ut: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/ut/main.ut -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/ut/utPLSQL/utplsql.sql: -------------------------------------------------------------------------------- 1 | select * form emp 2 | / -------------------------------------------------------------------------------- /devops/cicd/sample_nodeJS_DB_app/version.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/cicd/sample_nodeJS_DB_app/version.txt -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-ORM/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools - DevOPs - Terraform - Vanity URLs for Autonomous Oracle Database without customer managed Oracle REST Data Services Plus Plus 2 | 3 | ## Now with MORE Variables!!!!!! 4 | 5 | This project is a terraform script to help register a Vanity URL on an Autonomous Oracle Database instance in OCI without the need for creating and maintaining an ORDS instance on compute. Just provide your certs, the Autonomous Oracle Database OCID and off you go! 6 | 7 | All you need before you start is a VCN with an internet gateway and an ADB-S with a Private Endpoint pre-created. (You can use the VCN Quickstart to create a VCN in just 2 clicks) 8 | 9 | It creates the following: 10 | - A Public Subnet in an existing VCN 11 | - Security Lists for access over 443 12 | - A Load Balancer (always free 10Mbps-Micro) 13 | 14 | **The IPs for the Public Subnet assume you have a VNC with a CIDR block of 10.0.0.0/16 and 10.0.11.0/24 is unused.** 15 | 16 | When the script is finished, you can associate the public IP of the load balancer with your domain provider. 17 | 18 | ## The Variables (in the variables.tf file) 19 | 20 | ### Environment 21 | 22 | **region**: What region you are in. Example would be us-ashburn-1 23 | 24 | **tenancy_ocid**: The OCID of your tenancy 25 | 26 | **vcn_ocid**: The OCID of the existing VCN you want to use 27 | 28 | **compartment_ocid**: The OCID of an existing compartment where you want to place these resources 29 | 30 | **adb_ocid**: The OCID of the existing ADB-S you want to use 31 | 32 | ### Certificate Variables 33 | 34 | **certificate_certificate_name**: A display name for the cert 35 | 36 | **certificate_ca_certificate**: The text for the certificate, usually enclosed by -----BEGIN CERTIFICATE----- 37 | 38 | **certificate_private_key**: The text for the certificate private key, usually enclosed by -----END RSA PRIVATE KEY----- 39 | 40 | **certificate_public_certificate**: The text for the public certificate, usually enclosed by -----BEGIN CERTIFICATE----- 41 | 42 | The text for the certificates/key are multi-line and need to be enclosed with EOT as in the example here: 43 | 44 | ``` 45 | variable "certificate_public_certificate" { 46 | 47 | default = <<-EOT 48 | -----BEGIN CERTIFICATE----- 49 | MIIGSDCCBTCgAwIBAgISA+V2MiuwZLh0jNru+kjD8LzMMA0GCSqGSIb3DQEBCwUA 50 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 51 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 52 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 53 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 54 | ZFbRw5RCOle7+tMWK/pgHJGeQF7qXB4r0r24ByEQV+SRtn110xpbaG1RLBnmHkNu 55 | /Mqdp1KRIcH+DOuaR56oybAehQEOnsfkyBXAqikLdAqWNfP1ONjxVdzrSi3XkrYL 56 | Ct2wXiFoz/mmTjUtBFMYfkTxPBpJMisMhjS+j9iofEXNok94m592YH1/IAPiQ0yP 57 | ..... 58 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 59 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 60 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 61 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 62 | -----END CERTIFICATE----- 63 | EOT 64 | 65 | } 66 | ``` -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-ORM/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | variable "tenancy_ocid" { 10 | # OCID of your OCI Account Tenancy 11 | default = "xxxxxx" 12 | } 13 | 14 | variable "vcn_ocid" { 15 | # if using an existing VCN, add the OCID here: 16 | # Assumption is that the vcn cidr = "10.0.0.0/16" 17 | # If using a different CIDR, you will need to make the changes in the terraform file 18 | # 19 | default = "xxxxxx" 20 | 21 | } 22 | 23 | variable "compartment_ocid" { 24 | # OCID of the compartment the existing VCN is in 25 | default = "xxxxxx" 26 | } 27 | 28 | variable "adb_ocid" { 29 | # OCID of your Autonomous Database you wish to use 30 | default = "xxxxxx" 31 | } 32 | 33 | 34 | # Cert Variables 35 | 36 | variable "certificate_certificate_name"{ 37 | 38 | default = "xxxxxx" 39 | 40 | } 41 | 42 | variable "certificate_ca_certificate" { 43 | 44 | default = "xxxxxx" 45 | 46 | } 47 | 48 | variable "certificate_private_key" { 49 | 50 | default = "xxxxxx" 51 | 52 | } 53 | 54 | variable "certificate_public_certificate" { 55 | 56 | default = "xxxxxx" 57 | 58 | } -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-URL-without-customer-managed-ORDS-plus/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools - DevOPs - Terraform - Vanity URLs for Autonomous Oracle Database without customer managed Oracle REST Data Services Plus Plus 2 | 3 | ## Now with MORE Variables!!!!!! 4 | 5 | This project is a terraform script to help register a Vanity URL on an Autonomous Oracle Database instance in OCI without the need for creating and maintaining an ORDS instance on compute. Just provide your certs, the Autonomous Oracle Database OCID and off you go! 6 | 7 | All you need before you start is a VCN with an internet gateway and an ADB-S with a Private Endpoint pre-created. (You can use the VCN Quickstart to create a VCN in just 2 clicks) 8 | 9 | It creates the following: 10 | - A Public Subnet in an existing VCN 11 | - Security Lists for access over 443 12 | - A Load Balancer (always free 10Mbps-Micro) 13 | 14 | **The IPs for the Public Subnet assume you have a VNC with a CIDR block of 10.0.0.0/16 and 10.0.11.0/24 is unused.** 15 | 16 | When the script is finished, you can associate the public IP of the load balancer with your domain provider. 17 | 18 | ## The Variables (in the variables.tf file) 19 | 20 | ### Environment 21 | 22 | **region**: What region you are in. Example would be us-ashburn-1 23 | 24 | **tenancy_ocid**: The OCID of your tenancy 25 | 26 | **vcn_ocid**: The OCID of the existing VCN you want to use 27 | 28 | **compartment_ocid**: The OCID of an existing compartment where you want to place these resources 29 | 30 | **adb_ocid**: The OCID of the existing ADB-S you want to use 31 | 32 | ### Certificate Variables 33 | 34 | **certificate_certificate_name**: A display name for the cert 35 | 36 | **certificate_ca_certificate**: The text for the certificate, usually enclosed by -----BEGIN CERTIFICATE----- 37 | 38 | **certificate_private_key**: The text for the certificate private key, usually enclosed by -----END RSA PRIVATE KEY----- 39 | 40 | **certificate_public_certificate**: The text for the public certificate, usually enclosed by -----BEGIN CERTIFICATE----- 41 | 42 | The text for the certificates/key are multi-line and need to be enclosed with EOT as in the example here: 43 | 44 | ``` 45 | variable "certificate_public_certificate" { 46 | 47 | default = <<-EOT 48 | -----BEGIN CERTIFICATE----- 49 | MIIGSDCCBTCgAwIBAgISA+V2MiuwZLh0jNru+kjD8LzMMA0GCSqGSIb3DQEBCwUA 50 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 51 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 52 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 53 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 54 | ZFbRw5RCOle7+tMWK/pgHJGeQF7qXB4r0r24ByEQV+SRtn110xpbaG1RLBnmHkNu 55 | /Mqdp1KRIcH+DOuaR56oybAehQEOnsfkyBXAqikLdAqWNfP1ONjxVdzrSi3XkrYL 56 | Ct2wXiFoz/mmTjUtBFMYfkTxPBpJMisMhjS+j9iofEXNok94m592YH1/IAPiQ0yP 57 | ..... 58 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 59 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 60 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 61 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 62 | -----END CERTIFICATE----- 63 | EOT 64 | 65 | } 66 | ``` -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-URL-without-customer-managed-ORDS-plus/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | variable "tenancy_ocid" { 10 | # OCID of your OCI Account Tenancy 11 | default = "xxxxxx" 12 | } 13 | 14 | variable "vcn_ocid" { 15 | # if using an existing VCN, add the OCID here: 16 | # Assumption is that the vcn cidr = "10.0.0.0/16" 17 | # If using a different CIDR, you will need to make the changes in the terraform file 18 | # 19 | default = "xxxxxx" 20 | 21 | } 22 | 23 | variable "compartment_ocid" { 24 | # OCID of the compartment the existing VCN is in 25 | default = "xxxxxx" 26 | } 27 | 28 | variable "adb_ocid" { 29 | # OCID of your Autonomous Database you wish to use 30 | default = "xxxxxx" 31 | } 32 | 33 | 34 | # Cert Variables 35 | 36 | variable "certificate_certificate_name"{ 37 | 38 | default = "xxxxxx" 39 | 40 | } 41 | 42 | variable "certificate_ca_certificate" { 43 | 44 | default = "xxxxxx" 45 | 46 | } 47 | 48 | variable "certificate_private_key" { 49 | 50 | default = "xxxxxx" 51 | 52 | } 53 | 54 | variable "certificate_public_certificate" { 55 | 56 | default = "xxxxxx" 57 | 58 | } -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-URL-without-customer-managed-ORDS/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools - DevOPs - Terraform - Vanity URLs for Autonomous Oracle Database without customer managed Oracle REST Data Services 2 | 3 | This project is a terraform script to help register a Vanity URL on an Autonomous Oracle Database instance in OCI without the need for creating and maintaining an ORDS instance on compute. Just provide your certs, the Autonomous Oracle Database OCID and off you go! 4 | 5 | All you need before you start is a VCN with an internet gateway and an ADB-S with a Private Endpoint pre-created. (You can use the VCN Quickstart to create a VCN in just 2 clicks) 6 | 7 | It creates the following: 8 | - A Public Subnet in an existing VCN 9 | - Security Lists for access over 443 10 | - A Load Balancer (always free 10Mbps-Micro) 11 | 12 | **The IPs for the Public Subnet assume you have a VNC with a CIDR block of 10.0.0.0/16 and 10.0.11.0/24 is unused.** 13 | 14 | When the script is finished, you can associate the public IP of the load balancer with your domain provider. 15 | 16 | ## The Variables (in the variables.tf file) 17 | 18 | ### Environment 19 | 20 | **region**: What region you are in. Example would be us-ashburn-1 21 | 22 | **tenancy_ocid**: The OCID of your tenancy 23 | 24 | **vcn_ocid**: The OCID of the existing VCN you want to use 25 | 26 | **compartment_ocid**: The OCID of an existing compartment where you want to place these resources 27 | 28 | **adb_ocid**: The OCID of the existing ADB-S you want to use 29 | 30 | **backend_port**: Port used for the Load Balancer to talk to the ADB-S. Is set to 443. 31 | 32 | ### Certificate Variables 33 | 34 | **certificate_certificate_name**: A display name for the cert 35 | 36 | **certificate_ca_certificate**: The text for the certificate, usually enclosed by -----BEGIN CERTIFICATE----- 37 | 38 | **certificate_private_key**: The text for the certificate private key, usually enclosed by -----END RSA PRIVATE KEY----- 39 | 40 | **certificate_public_certificate**: The text for the public certificate, usually enclosed by -----BEGIN CERTIFICATE----- 41 | 42 | The text for the certificates/key are multi-line and need to be enclosed with EOT as in the example here: 43 | 44 | ``` 45 | variable "certificate_public_certificate" { 46 | 47 | default = <<-EOT 48 | -----BEGIN CERTIFICATE----- 49 | MIIGSDCCBTCgAwIBAgISA+V2MiuwZLh0jNru+kjD8LzMMA0GCSqGSIb3DQEBCwUA 50 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 51 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 52 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 53 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 54 | ZFbRw5RCOle7+tMWK/pgHJGeQF7qXB4r0r24ByEQV+SRtn110xpbaG1RLBnmHkNu 55 | /Mqdp1KRIcH+DOuaR56oybAehQEOnsfkyBXAqikLdAqWNfP1ONjxVdzrSi3XkrYL 56 | Ct2wXiFoz/mmTjUtBFMYfkTxPBpJMisMhjS+j9iofEXNok94m592YH1/IAPiQ0yP 57 | ..... 58 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 59 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 60 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 61 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 62 | -----END CERTIFICATE----- 63 | EOT 64 | 65 | } 66 | ``` -------------------------------------------------------------------------------- /devops/terraform/ADB-Vanity-URL-without-customer-managed-ORDS/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | variable "tenancy_ocid" { 10 | # OCID of your OCI Account Tenancy 11 | default = "xxxxxx" 12 | } 13 | 14 | variable "vcn_ocid" { 15 | # if using an existing VCN, add the OCID here: 16 | # Assumption is that the vcn cidr = "10.0.0.0/16" 17 | # If using a different CIDR, you will need to make the changes in the terraform file 18 | # 19 | default = "xxxxxx" 20 | 21 | } 22 | 23 | variable "compartment_ocid" { 24 | # OCID of the compartment the existing VCN is in 25 | default = "xxxxxx" 26 | } 27 | 28 | variable "adb_ocid" { 29 | # OCID of your Autonomous Database you wish to use 30 | default = "xxxxxx" 31 | } 32 | 33 | 34 | # Cert Variables 35 | 36 | variable "certificate_certificate_name"{ 37 | 38 | default = "xxxxxx" 39 | 40 | } 41 | 42 | variable "certificate_ca_certificate" { 43 | 44 | default = "xxxxxx" 45 | 46 | } 47 | 48 | variable "certificate_private_key" { 49 | 50 | default = "xxxxxx" 51 | 52 | } 53 | 54 | variable "certificate_public_certificate" { 55 | 56 | default = "xxxxxx" 57 | 58 | } -------------------------------------------------------------------------------- /devops/terraform/Jenkins/README.md: -------------------------------------------------------------------------------- 1 | For OCI and Jenkins 2 | https://github.com/oracle-quickstart/oci-arch-ci-cd -------------------------------------------------------------------------------- /devops/terraform/ORDS_dbcs/ords_params.properties: -------------------------------------------------------------------------------- 1 | # 2 | # DB Connect Info 3 | db.connectionType=basic 4 | db.hostname= 5 | db.port= 6 | db.servicename= 7 | sys.user=SYS 8 | sys.password= 9 | 10 | # for APEX (not supported via this terraform script at this time) 11 | plsql.gateway.add=false 12 | rest.services.apex.add=false 13 | 14 | 15 | # for ORDS 16 | rest.services.ords.add=true 17 | user.public.password= 18 | schema.tablespace.default=SYSAUX 19 | schema.tablespace.temp=TEMP 20 | user.tablespace.default=SYSAUX 21 | user.tablespace.temp=TEMP 22 | 23 | # for standalone mode that uses self signed cert 24 | standalone.mode=true 25 | standalone.http.port=8080 26 | standalone.use.https=true 27 | standalone.https.port=8443 28 | standalone.static.images=/opt/oracle/ords/apex/images 29 | standalone.ssl.host=localhost 30 | standalone.use.ssl.cert=false 31 | 32 | # for SDW/Database Actions 33 | feature.sdw=true 34 | restEnabledSql.active=true 35 | database.api.enabled=true -------------------------------------------------------------------------------- /devops/terraform/ORDS_dbcs/variables.tf: -------------------------------------------------------------------------------- 1 | # Variables for ORDS Only install 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | 10 | variable "tenancy_ocid" { 11 | # OCID of your OCI Account Tenancy 12 | default = "xxxxxx" 13 | } 14 | 15 | variable "vcn_ocid" { 16 | # if using an existing VCN, add the OCID here: 17 | # Assumption is that the vcn cidr = "10.0.0.0/16" 18 | # If using a different CIDR, you will need to make the changes in the terraform file 19 | # 20 | default = "xxxxx" 21 | 22 | } 23 | 24 | 25 | variable "vm_shape" { 26 | # shape/type of VM 27 | # choose from: VM.Standard.E2.1.Micro, VM.Standard.E4.Flex, VM.Standard.A1.Flex 28 | # if using VM.Standard.E4.Flex or VM.Standard.A1.Flex you must add the folowing lines to define the shape 29 | # for VM.Standard.A1.Flex, you can have up to 4 OCPUs and 24 gb of memory for free. 30 | # shape_config { 31 | # memory_in_gbs = "24" 32 | # ocpus = "4" 33 | # } 34 | default = "xxxxxx" 35 | } 36 | 37 | variable "number_of_midtiers" { 38 | # how many midtiers you want to create 39 | default = 1 40 | } 41 | 42 | 43 | ## These Variables are not used at this time 44 | 45 | # variable "ssh_public_key" { 46 | # default = "xxxxxx" 47 | # } 48 | 49 | # variable "ssh_private_key" { 50 | # default = "xxxxxx" 51 | # } -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ADB-PE/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools - DevOPs - Terraform - Vanity URLs 2 | 3 | This project is a terraform script to help register a Vanity URL on an ADB instance in OCI. 4 | 5 | It creates the following: 6 | - VCN and Public Subnet 7 | - Security Lists for access over 443 and 8080 8 | - A Load Balancer 9 | - A compute instance (full or micro) 10 | - Installs ORDS, SQLcl and stages the APEX images 11 | - Uses LetsEncrypt to get the certs for your customer domain 12 | - Starts up ORDS connected to an ADB instance on 443 with the certs installed 13 | 14 | The Variables.tf file can be used to tell terraform what ADB instance you are going to use and what your custom domain is named. 15 | 16 | ## Two Versions 17 | 18 | There are 2 terraform files in the directory. You can only have one when running. 19 | 20 | completeSetupFullVM is for full compute instance for ORDS 21 | 22 | shape = "VM.Standard.E3.Flex" 23 | 24 | completeSetupMicroVM is for always free compute for ORDS 25 | 26 | shape = "VM.Standard.E2.1.Micro" 27 | 28 | both files use an always free load balancer but can be changed 29 | 30 | shape = "10Mbps-Micro" 31 | 32 | ## IP Addresses and Domain Name Providers 33 | 34 | You will need to update your domain register to point to the public IPs of the load balancer as this script runs. There is a sleep point for 210 seconds in the setup terraform script where you can perform this procedure. You can increase this timeout if needed. 35 | 36 | ## SSH Keys 37 | 38 | In the setup terraform script, you will need to supply the path to the SSH keys you wish to use. Find the **private_key** and **ssh_authorized_keys** attributes and set as appropriate. 39 | For example, if I was using the OCI cloud shell and had my keys there, my path would be similar to: 40 | 41 | ssh_authorized_keys = file("/home/bspendol/terraform/compute.pub") 42 | 43 | private_key = file("/home/bspendol/terraform/compute.ppk") 44 | 45 | ## Setting up the PAR URLs for the static files 46 | 47 | In the terraform scripts, you will see entries for 48 | APEX_PAR_URL 49 | ORDS_CONF_PAR_URL 50 | 51 | The first one needs to be replaced with an OCI Object Store PAR for where you have staged the apex install zip 52 | The second one needs to be replaced with an OCI Object Store PAR for where you have staged the ords_conf.zip file that is contained in this project. -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ADB-PE/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "eu-frankfurt-1" 7 | } 8 | 9 | variable "tenancy_ocid" { 10 | # OCID of your OCI Account Tenancy 11 | default = "ocid1.tenancy.oc1..aaaaaaaambnyexdtahy6ug7dy2ngnfnthvvbpfgmgmg3slb73f52wkbudvwq" 12 | } 13 | 14 | variable "vcn_ocid" { 15 | # if using an existing VCN, add the OCID here: 16 | # Assumption is that the vcn cidr = "10.0.0.0/16" 17 | # If using a different CIDR, you will need to make the changes in the terraform file 18 | # 19 | default = "ocid1.vcn.oc1.eu-frankfurt-1.amaaaaaau3i6vkyaw7tkpopjkwxk47jbwqpwu2fq6gjwnnovib466hcccqga" 20 | 21 | } 22 | 23 | variable "compartment_ocid" { 24 | # OCID of the compartment the existing VCN is in 25 | default = "ocid1.compartment.oc1..aaaaaaaahn7oa3rb35pazqtcdnx57ws4wigtk3okssgh7pity6fikicucx4a" 26 | } 27 | 28 | variable "adb_ocid" { 29 | # OCID of your Autonomous Database you wish to use 30 | default = "ocid1.autonomousdatabase.oc1.eu-frankfurt-1.antheljtu3i6vkya75htav6wclgcopcqmty2wadgobtbtm6yox34f5z4iz2a" 31 | } 32 | 33 | 34 | # Cert Variables 35 | 36 | variable "certificate_certificate_name"{ 37 | 38 | default = "xxxx" 39 | 40 | } 41 | 42 | variable "certificate_ca_certificate" { 43 | 44 | default = "xxxx" 45 | 46 | } 47 | 48 | variable "certificate_private_key" { 49 | 50 | default = "xxxx" 51 | 52 | } 53 | 54 | variable "certificate_public_certificate" { 55 | 56 | default = "xxxx" 57 | 58 | } 59 | 60 | variable "backend_port" { 61 | 62 | default = "xxxx" 63 | 64 | } -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ResourceManager.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/terraform/VanityURL-ResourceManager.zip -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ResourceManager/README.md: -------------------------------------------------------------------------------- 1 | # **Work in progress!** 2 | 3 | In the mean time, here is a lizard dressed up as a shark 4 | 5 | ![lizard-shark](https://user-images.githubusercontent.com/69256666/134745733-73d16d24-6b48-4c59-8a29-044cf65679ef.jpg) 6 | 7 | 8 | # Oracle Database Tools - DevOPs - Terraform - Resource Manager Vanity URLs for Autonomous Oracle Database without customer managed Oracle REST Data Services 9 | 10 | This project is a terraform script to help register a Vanity URL on an Autonomous Oracle Database instance in OCI without the need for creating and maintaining an ORDS instance on compute. Just provide your certs, the Autonomous Oracle Database OCID and off you go! 11 | 12 | All you need before you start is a VCN with an internet gateway and an ADB-S with a Private Endpoint pre-created. (You can use the VCN Quickstart to create a VCN in just 2 clicks) 13 | 14 | It creates the following: 15 | - A Public Subnet in an existing VCN 16 | - Security Lists for access over 443 17 | - A Load Balancer (always free 10Mbps-Micro) 18 | 19 | **The IPs for the Public Subnet assume you have a VNC with a CIDR block of 10.0.0.0/16 and 10.0.11.0/24 is unused.** 20 | 21 | When the script is finished, you can associate the public IP of the load balancer with your domain provider. 22 | 23 | ## The Variables (in the variables.tf file) 24 | 25 | ### Environment 26 | 27 | **region**: What region you are in. Example would be us-ashburn-1 28 | 29 | **tenancy_ocid**: The OCID of your tenancy 30 | 31 | **vcn_ocid**: The OCID of the existing VCN you want to use 32 | 33 | **compartment_ocid**: The OCID of an existing compartment where you want to place these resources 34 | 35 | **adb_ocid**: The OCID of the existing ADB-S you want to use 36 | 37 | **backend_port**: Port used for the Load Balancer to talk to the ADB-S. Is set to 443. 38 | 39 | ### Certificate Variables 40 | 41 | **certificate_certificate_name**: A display name for the cert 42 | 43 | **certificate_ca_certificate**: The text for the certificate, usually enclosed by -----BEGIN CERTIFICATE----- 44 | 45 | **certificate_private_key**: The text for the certificate private key, usually enclosed by -----END RSA PRIVATE KEY----- 46 | 47 | **certificate_public_certificate**: The text for the public certificate, usually enclosed by -----BEGIN CERTIFICATE----- 48 | 49 | The text for the certificates/key are multi-line and need to be enclosed with EOT as in the example here: 50 | 51 | ``` 52 | variable "certificate_public_certificate" { 53 | 54 | default = <<-EOT 55 | -----BEGIN CERTIFICATE----- 56 | MIIGSDCCBTCgAwIBAgISA+V2MiuwZLh0jNru+kjD8LzMMA0GCSqGSIb3DQEBCwUA 57 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 58 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 59 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 60 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 61 | ZFbRw5RCOle7+tMWK/pgHJGeQF7qXB4r0r24ByEQV+SRtn110xpbaG1RLBnmHkNu 62 | /Mqdp1KRIcH+DOuaR56oybAehQEOnsfkyBXAqikLdAqWNfP1ONjxVdzrSi3XkrYL 63 | Ct2wXiFoz/mmTjUtBFMYfkTxPBpJMisMhjS+j9iofEXNok94m592YH1/IAPiQ0yP 64 | ..... 65 | MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD 66 | EwJSMzAeFw0yMTA4MjUxNjU2NDBaFw0yMTExMjMxNjU2MzlaMB8xHTAbBgNVBAMT 67 | FGRpbm9zYXVyZm9vdGJhbGwuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 68 | CgKCAgEAzBfcuiZATNwQgaoM5F88jOR+lJ4oDPTNPc+eXy62Pqb5aJFiHtM4I+RX 69 | -----END CERTIFICATE----- 70 | EOT 71 | 72 | } 73 | ``` 74 | -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ResourceManager/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "" 7 | } 8 | 9 | variable "tenancy_ocid" { 10 | # OCID of your OCI Account Tenancy 11 | default = "" 12 | } 13 | 14 | variable "vcn_ocid" { 15 | # if using an existing VCN, add the OCID here: 16 | # Assumption is that the vcn cidr = "10.0.0.0/16" 17 | # If using a different CIDR, you will need to make the changes in the terraform file 18 | # 19 | default = "" 20 | 21 | } 22 | 23 | variable "cidr_block" { 24 | 25 | default = "10.0.11.0/24" 26 | 27 | } 28 | 29 | variable "compartment_ocid" { 30 | # OCID of the compartment the existing VCN is in 31 | default = "" 32 | } 33 | 34 | # LB Vars 35 | 36 | variable "lb_shape" { 37 | 38 | default = "10Mbps-Micro" 39 | 40 | } 41 | 42 | variable "flex_lb_min_shape" { 43 | 44 | default = null 45 | 46 | } 47 | 48 | variable "flex_lb_max_shape" { 49 | 50 | default = null 51 | 52 | } 53 | 54 | # ADB Vars 55 | 56 | variable "autonomous_database" { 57 | # OCID of your Autonomous Database you wish to use 58 | default = "" 59 | } 60 | 61 | 62 | # Cert Variables 63 | 64 | variable "certificate_certificate_name"{ 65 | 66 | default = "" 67 | 68 | } 69 | 70 | variable "certificate_ca_certificate" { 71 | 72 | default = "" 73 | 74 | } 75 | 76 | variable "certificate_private_key" { 77 | 78 | default = "" 79 | 80 | } 81 | 82 | variable "certificate_public_certificate" { 83 | 84 | default = "" 85 | 86 | } -------------------------------------------------------------------------------- /devops/terraform/VanityURL-ResourceManager/schema.yaml: -------------------------------------------------------------------------------- 1 | ## Copyright © 2021, Oracle and/or its affiliates. 2 | ## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl 3 | ## Database Development Tools - btspendo 4 | 5 | title: "Use a Vanity URL on an Autonomous Database" 6 | stackDescription: "Use a Vanity URL on an Autonomous Database." 7 | schemaVersion: 1.0.0 8 | version: "20210720" 9 | locale: "en" 10 | 11 | variableGroups: 12 | - title: General Configuration 13 | visible: false 14 | variables: 15 | - tenancy_ocid 16 | - release 17 | 18 | - title: Load Balancer Configuration 19 | visible: true 20 | variables: 21 | - lb_shape 22 | - flex_lb_min_shape 23 | - flex_lb_max_shape 24 | 25 | - title: Required Configuration 26 | visible: true 27 | variables: 28 | - region 29 | - vcn_ocid 30 | - cidr_block 31 | - compartment_ocid 32 | - autonomous_database 33 | - certificate_certificate_name 34 | - certificate_ca_certificate 35 | - certificate_public_certificate 36 | - certificate_private_key 37 | 38 | variables: 39 | 40 | compartment_ocid: 41 | type: oci:identity:compartment:id 42 | required: true 43 | visible: true 44 | title: Compartment 45 | description: "Compartment where you want to create the solution resources" 46 | 47 | region: 48 | type: oci:identity:region:name 49 | required: true 50 | visible: true 51 | title: Region 52 | description: "Region where you want to deploy the resources defined by this stack." 53 | 54 | 55 | lb_shape: 56 | type: enum 57 | title: "Load Balancer Shape" 58 | description: "Load Balancer Shape" 59 | default: "flexible" 60 | required: true 61 | enum: 62 | - "flexible" 63 | - "100Mbps" 64 | - "10Mbps" 65 | - "10Mbps-Micro" 66 | - "400Mbps" 67 | - "8000Mbps" 68 | 69 | flex_lb_min_shape: 70 | type: enum 71 | required: false 72 | default: "10" 73 | title: "LB Flex Min Shape" 74 | description: "Choose Minimum Shape for Flex Load Balancer." 75 | enum: 76 | - "10" 77 | - "100" 78 | - "1000" 79 | - "400" 80 | - "8000" 81 | visible: 82 | and: 83 | - eq: 84 | - lb_shape 85 | - "flexible" 86 | 87 | flex_lb_max_shape: 88 | type: enum 89 | required: false 90 | default: "100" 91 | title: "LB Flex Max Shape" 92 | description: "Choose Maximum Shape for Flex Load Balancer." 93 | enum: 94 | - "10" 95 | - "100" 96 | - "1000" 97 | - "400" 98 | - "8000" 99 | visible: 100 | and: 101 | - eq: 102 | - lb_shape 103 | - "flexible" 104 | 105 | vcn_ocid: 106 | type: oci:core:vcn:id 107 | required: true 108 | visible: true 109 | title: "Virtual Cloud Network" 110 | description: "Virtual Cloud Network" 111 | dependsOn: 112 | compartmentId: ${compartment_ocid} 113 | 114 | cidr_block: 115 | type: string 116 | required: true 117 | visible: true 118 | title: "CIDR Block for Public Subnet" 119 | 120 | autonomous_database: 121 | type: oci:database:autonomousdatabase:id 122 | required: true 123 | visible: true 124 | title: "Autonomous Database" 125 | description: "Autonomous Database" 126 | dependsOn: 127 | compartmentId: ${compartment_ocid} 128 | 129 | certificate_certificate_name: 130 | type: string 131 | required: true 132 | visible: true 133 | title: "Certificate Name" 134 | 135 | certificate_ca_certificate: 136 | type: string 137 | required: true 138 | visible: true 139 | title: "Certificate Text" 140 | 141 | certificate_public_certificate: 142 | type: string 143 | required: true 144 | visible: true 145 | title: "Public Certificate Text" 146 | 147 | certificate_private_key: 148 | type: string 149 | required: true 150 | visible: true 151 | title: "Certificate Key Text" 152 | 153 | 154 | 155 | outputs: 156 | 157 | loadbalancer_public_url: 158 | title: "Loadbalancer Public URL" 159 | displayText: "Loadbalancer Public URL" 160 | type: string 161 | visible: true -------------------------------------------------------------------------------- /devops/terraform/vanityURL-ADB/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Tools - DevOPs - Terraform - Vanity URLs 2 | 3 | This project is a terraform script to help register a Vanity URL on an ADB instance in OCI. 4 | 5 | It creates the following: 6 | - VCN and Public Subnet 7 | - Security Lists for access over 443 and 8080 8 | - A Load Balancer 9 | - A compute instance (full or micro) 10 | - Installs ORDS, SQLcl and stages the APEX images 11 | - Uses LetsEncrypt to get the certs for your customer domain 12 | - Starts up ORDS connected to an ADB instance on 443 with the certs installed 13 | 14 | The Variables.tf file can be used to tell terraform what ADB instance you are going to use and what your custom domain is named. 15 | 16 | ## Two Versions 17 | 18 | There are 2 terraform files in the directory. You can only have one when running. 19 | 20 | completeSetupFullVM is for full compute instance for ORDS 21 | 22 | shape = "VM.Standard.E3.Flex" 23 | 24 | completeSetupMicroVM is for always free compute for ORDS 25 | 26 | shape = "VM.Standard.E2.1.Micro" 27 | 28 | both files use an always free load balancer but can be changed 29 | 30 | shape = "10Mbps-Micro" 31 | 32 | ## IP Addresses and Domain Name Providers 33 | 34 | You will need to update your domain register to point to the public IPs of the load balancer as this script runs. There is a sleep point for 210 seconds in the setup terraform script where you can perform this procedure. You can increase this timeout if needed. 35 | 36 | ## SSH Keys 37 | 38 | In the setup terraform script, you will need to supply the path to the SSH keys you wish to use. Find the **private_key** and **ssh_authorized_keys** attributes and set as appropriate. 39 | For example, if I was using the OCI cloud shell and had my keys there, my path would be similar to: 40 | 41 | ssh_authorized_keys = file("/home/bspendol/terraform/compute.pub") 42 | 43 | private_key = file("/home/bspendol/terraform/compute.ppk") 44 | 45 | ## Setting up the PAR URLs for the static files 46 | 47 | In the terraform scripts, you will see entries for 48 | APEX_PAR_URL 49 | ORDS_CONF_PAR_URL 50 | 51 | The first one needs to be replaced with an OCI Object Store PAR for where you have staged the apex install zip 52 | The second one needs to be replaced with an OCI Object Store PAR for where you have staged the ords_conf.zip file that is contained in this project. -------------------------------------------------------------------------------- /devops/terraform/vanityURL-ADB/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | variable "admin_password" { 10 | #admin password of the autonomous database you want to use 11 | default = "xxxxxx" 12 | } 13 | 14 | variable "tenency_ocid" { 15 | # OCID of your OCI Account Tenancy 16 | default = "xxxxxx" 17 | } 18 | 19 | variable "adb_ocid" { 20 | # OCID of your Autonomous Database you wish to use 21 | default = "xxxxxx" 22 | } 23 | 24 | variable "database_name" { 25 | # Name of the autonomous database you wish to use 26 | default = "xxxxxx" 27 | } 28 | 29 | variable "domain_name" { 30 | # Your domain name you wish to use and own 31 | default = "xxxxxx" 32 | } 33 | 34 | variable "number_of_midtiers" { 35 | # how many midtiers you want to create 36 | default = 1 37 | } 38 | 39 | ## These Variables are not used at this time 40 | 41 | variable "ssh_public_key" { 42 | default = "xxxxxx" 43 | } 44 | 45 | variable "ssh_private_key" { 46 | default = "xxxxxx" 47 | } -------------------------------------------------------------------------------- /devops/terraform/vanityURL-ADB/ords_conf.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/terraform/vanityURL-ADB/ords_conf.zip -------------------------------------------------------------------------------- /devops/terraform/vanityURL-DBCS/Variables.tf: -------------------------------------------------------------------------------- 1 | # Variables 2 | # Please fill in the xxxxxx with your account values 3 | 4 | variable "region" { 5 | # sample: eu-frankfurt-1 6 | default = "xxxxxx" 7 | } 8 | 9 | 10 | variable "tenancy_ocid" { 11 | # OCID of your OCI Account Tenancy 12 | default = "xxxxxx" 13 | } 14 | 15 | variable "vcn_ocid" { 16 | # if using an existing VCN, add the OCID here: 17 | # Assumption is that the vcn cidr = "10.0.0.0/16" 18 | # If using a different CIDR, you will need to make the changes in the terraform file 19 | # 20 | default = "xxxxx" 21 | 22 | } 23 | 24 | 25 | variable "vm_shape" { 26 | # shape/type of VM 27 | # choose from: VM.Standard.E2.1.Micro, VM.Standard.E4.Flex, VM.Standard.A1.Flex 28 | # if using VM.Standard.E4.Flex or VM.Standard.A1.Flex you must add the folowing lines to define the shape 29 | # for VM.Standard.A1.Flex, you can have up to 4 OCPUs and 24 gb of memory for free. 30 | # shape_config { 31 | # memory_in_gbs = "24" 32 | # ocpus = "4" 33 | # } 34 | default = "xxxxxx" 35 | } 36 | 37 | variable "domain_name" { 38 | # Your domain name you wish to use and own 39 | default = "xxxxxx" 40 | } 41 | 42 | variable "number_of_midtiers" { 43 | # how many midtiers you want to create 44 | default = 1 45 | } 46 | 47 | 48 | ## These Variables are not used at this time 49 | 50 | variable "ssh_public_key" { 51 | default = "xxxxxx" 52 | } 53 | 54 | variable "ssh_private_key" { 55 | default = "xxxxxx" 56 | } -------------------------------------------------------------------------------- /devops/terraform/vanityURL-DBCS/images/hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/devops/terraform/vanityURL-DBCS/images/hover.png -------------------------------------------------------------------------------- /devops/terraform/vanityURL-DBCS/ords_params.properties: -------------------------------------------------------------------------------- 1 | # 2 | # DB Connect Info 3 | db.connectionType=basic 4 | db.hostname= 5 | db.port= 6 | db.servicename= 7 | sys.user=SYS 8 | sys.password= 9 | 10 | # for APEX (not supported via this terraform script at this time) 11 | plsql.gateway.add=false 12 | #db.username=APEX_PUBLIC_USER 13 | #db.password= 14 | rest.services.apex.add=false 15 | #user.apex.listener.password= 16 | #user.apex.restpublic.password= 17 | #migrate.apex.rest=false 18 | 19 | # for ORDS 20 | rest.services.ords.add=true 21 | user.public.password= 22 | schema.tablespace.default=SYSAUX 23 | schema.tablespace.temp=TEMP 24 | user.tablespace.default=SYSAUX 25 | user.tablespace.temp=TEMP 26 | 27 | # for standalone mode 28 | standalone.mode=true 29 | standalone.http.port=8080 30 | standalone.use.https=false 31 | standalone.static.images=/opt/oracle/ords/apex/images 32 | 33 | # for SDW/Database Actions 34 | feature.sdw=true 35 | restEnabledSql.active=true 36 | database.api.enabled=true -------------------------------------------------------------------------------- /devops/terraform/vanityURL-DBCS/standalone.properties.SSL: -------------------------------------------------------------------------------- 1 | #Wed Dec 16 07:06:43 UTC 2020 2 | #jetty.port=8080 3 | jetty.secure.port=443 4 | ssl.cert=/opt/oracle/ords/conf/ords/standalone/domain.crt 5 | ssl.cert.key=/opt/oracle/ords/conf/ords/standalone/domain.pkcs8.der 6 | standalone.context.path=/ords 7 | standalone.doc.root=/opt/oracle/ords/conf/ords/standalone/doc_root 8 | standalone.scheme.do.not.prompt=true 9 | standalone.static.context.path=/i/20.2.0.00.20/ 10 | standalone.static.path=/opt/oracle/ords/apex/images -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Working with Oracle REST Data Services (ORDS) Examples 2 | 3 | ## Current Examples and Walk-throughs 4 | 5 | - [Using the Logging Service in OCI with ORDS](./oci/ords-oci-logging.md) 6 | - [Using the Bastion as a Service to access OCI Cloud Databases/ORDS/Database Actions using Private IPs](./oci/bastion-dbcs.md) 7 | 8 | 9 | ## Current Livelabs 10 | 11 | - [Modern App Dev with Oracle REST Data Services](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=815&clear=180&session=109157054651263) 12 | - [Choose your Own JSON Adventure: Relational or Document Store](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=813&clear=180&session=109157054651263) 13 | - [RESTful Services for your Autonomous Database](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=578&clear=180&session=109157054651263) -------------------------------------------------------------------------------- /examples/oci/bastion-dbcs.md: -------------------------------------------------------------------------------- 1 | # Using Bastion as a Service for ADB/DBCS instances 2 | 3 | First we need some information from the ADB using the private endpoint. On the details page of the ADB using PE, find the Network section. 4 | 5 | ![ADB details page](./images/bast-1.png) 6 | 7 | Make note of the Private Endpoint IP and the Private Endpoint URL. 8 | 9 | Here our IP is 10.0.1.2 and the URL is tzuuetzj.adb.eu-frankfurt-1.oraclecloud.com 10 | 11 | 12 | Create a bastion in OCI via the OCI Web Console at Identity & Security → Bastion 13 | 14 | ![OCI Menu, navigate Identity & Security → Bastion](./images/bast-2.png) 15 | 16 | Click the Create Bastion button, use a public subnet and allow access from a CIDR block 17 | 18 | ![Click the Create Bastion button](./images/bast-3.png) 19 | 20 | View the details of the bastion and click the Create Session button 21 | 22 | ![View the details of the bastion and click the Create Session button](./images/bast-4.png) 23 | 24 | In the Create Session slider, set: 25 | 26 | **Session Type:** SSH port forwarding session 27 | 28 | ****IP Address:** IP of the ADB instance using a private endpoint (ie. 10.0.1.2) Remember, we noted this at the beginning when looking at our ADB Details page. 29 | 30 | **Port**: 1522 for SQL*Net access or 443 for HTTPS access (although the following screenshots show 22) 31 | 32 | **Add SSH Key:** Provide your own or use the generated one 33 | 34 | When done, click the Create Session button 35 | 36 | ![click the Create Session button](./images/bast-5.png) 37 | 38 | Once the session is created, use the pop out menu and select Copy SSH Command 39 | 40 | ![use the pop out menu and select Copy SSH Command](./images/bast-6.png) 41 | 42 | The SSH Command will look similar to the following: 43 | ``` 44 | ssh -i -N -L :10.0.1.2:22 -p 22 ocid1.bastionsession.oc1.eu-frankfurt-1.amaaaaaau3i6vkyaj347383023098230-9adsfhbzdxc09898h23r@host.bastion.eu-frankfurt-1.oci.oraclecloud.com 45 | ``` 46 | Change **** to be the matching private key to the public key you created the session with and change **** to be the port on your local machine you want to use. If using 443, you will have to run the command as an administrator on most unix/linux based systems but....... 47 | 48 | Before you run the command, you will need to alter your hosts file (/etc/hosts on unix/linux or C:\Windows\System32\Drivers\etc\hosts for Windows). Remember the Private Endpoint URL we noted on the ADB details page. Remember, your hostname will be different. 49 | 50 | **For SQL*Net Access:** 51 | 52 | Add the following entry if you want to connect via SQL*net 53 | 54 | 127.0.0.1 tzuuetzj.adb.eu-frankfurt-1.oraclecloud.com 55 | 56 | you may have to comment out localhost here 57 | 58 | 127.0.0.1 tzuuetzj.adb.eu-frankfurt-1.oraclecloud.com #localhost 59 | 60 | Hence with port 1522 (and ideally localPort equals to 1522 thus you don't need to change the wallet content, specifically the tnsnames.ora): 61 | ``` 62 | ssh -i -N -L 1522:10.0.1.2:1522 -p 22 ocid1.bastionsession.oc1.eu-frankfurt-1.amaaaaaau3i6vkyaj347383023098230-9adsfhbzdxc09898h23r@host.bastion.eu-frankfurt-1.oci.oraclecloud.com 63 | ``` 64 | 65 | **For HTTPS Access:** 66 | 67 | Add the following entry if you want to connect via HTTPS 68 | 69 | 127.0.0.1 tzuuetzj.adb.eu-frankfurt-1.oraclecloudapps.com 70 | 71 | you may have to comment out localhost here 72 | 73 | 127.0.0.1 tzuuetzj.adb.eu-frankfurt-1.oraclecloudapps.com #localhost 74 | 75 | Hence with port 443 (and ideally localPort equals to 443 thus you don't need to modify ORDS, SQL Developer Web... URLs): 76 | ``` 77 | ssh -i -N -L 443:10.0.1.2:443 -p 22 ocid1.bastionsession.oc1.eu-frankfurt-1.amaaaaaau3i6vkyaj347383023098230-9adsfhbzdxc09898h23r@host.bastion.eu-frankfurt-1.oci.oraclecloud.com 78 | ``` 79 | 80 | You can now go ahead and connect via SQL*Net as you would an ADB on a public IP with the wallet. 81 | 82 | If using HTTPS, you can get the URL via the tools subtab on the ADB details page. 83 | 84 | ![HTTPS, you can get the URL via the tools subtab on the ADB details page](./images/bast-7.png) 85 | 86 | Here our URL is https://tzuuetzj.adb.eu-frankfurt-1.oraclecloudapps.com/ords/sql-developer 87 | 88 | We can put that in a browser to access Database Actions 89 | 90 | ![URL in browser to access Database Actions](./images/bast-8.png) 91 | -------------------------------------------------------------------------------- /examples/oci/files/group.json: -------------------------------------------------------------------------------- 1 | { 2 | "groupList": [ 3 | "" 4 | ] 5 | } -------------------------------------------------------------------------------- /examples/oci/files/serv.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurationType": "LOGGING", 3 | "destination": { 4 | "logObjectId": "" 5 | }, 6 | "sources": [ 7 | { 8 | "name": "ordslog2", 9 | "parser": { 10 | "field-time-key": null, 11 | "is-estimate-current-event": null, 12 | "is-keep-time-key": null, 13 | "is-null-empty-string": null, 14 | "message-key": null, 15 | "null-value-pattern": null, 16 | "parser-type": "NONE", 17 | "timeout-in-milliseconds": null, 18 | "types": null 19 | }, 20 | "paths": [ 21 | "/home/opc/ords/conf/ords/standalone/logs/*.log" 22 | ], 23 | "source-type": "LOG_TAIL" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /examples/oci/images/bast-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-1.png -------------------------------------------------------------------------------- /examples/oci/images/bast-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-2.png -------------------------------------------------------------------------------- /examples/oci/images/bast-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-3.png -------------------------------------------------------------------------------- /examples/oci/images/bast-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-4.png -------------------------------------------------------------------------------- /examples/oci/images/bast-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-5.png -------------------------------------------------------------------------------- /examples/oci/images/bast-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-6.png -------------------------------------------------------------------------------- /examples/oci/images/bast-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-7.png -------------------------------------------------------------------------------- /examples/oci/images/bast-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/oci/images/bast-8.png -------------------------------------------------------------------------------- /examples/rest/README.md: -------------------------------------------------------------------------------- 1 | ## REST Examples using other platforms 2 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/README.md: -------------------------------------------------------------------------------- 1 | # ORDS and iOS 2 | Work in progress 3 | 4 | **to-do** 5 | pass geocoded coordinates to map 6 | clean up code 7 | add OAuth 2 8 | step-by-step directions -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone.xcodeproj/project.xcworkspace/xcuserdata/bspendol.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/examples/rest/xcode-iOS/ords_iPhone/ords_iPhone.xcodeproj/project.xcworkspace/xcuserdata/bspendol.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone.xcodeproj/xcuserdata/bspendol.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ords_iPhone.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FetchView.swift 3 | // 4 | // Created by Roberto Breve on 4.10.2019. 5 | // Copyright © 2019 Roberto Breve . All rights reserved. 6 | // 7 | import Foundation 8 | import SwiftUI 9 | import Combine 10 | 11 | struct Response: Codable { 12 | var items: [items] 13 | } 14 | 15 | struct items: Codable { 16 | var id: Int 17 | var name: String 18 | var phone: String 19 | var address: String 20 | var city: String 21 | var state: String 22 | var zip: String 23 | } 24 | 25 | struct ContentView: View { 26 | 27 | @State var results = [items]() 28 | 29 | var body: some View { 30 | NavigationView { 31 | List(results.sorted { $1.id > $0.id}, id: \.id) { items in 32 | empSelect(items: items) 33 | } 34 | .onAppear(perform: loadData) 35 | .navigationBarTitle(Text("ORDS on iOS")) 36 | } 37 | 38 | } 39 | 40 | func loadData() { 41 | 42 | guard let url = URL(string: "https://REST_URL/") else { 43 | print("Invalid URL") 44 | return 45 | } 46 | 47 | let request = URLRequest(url: url) 48 | 49 | URLSession.shared.dataTask(with: request) { data, response, error in 50 | if let data = data { 51 | 52 | if let decodedResponse = try? JSONDecoder().decode(Response.self, from: data) { 53 | // we have good data – go back to the main thread 54 | DispatchQueue.main.async { 55 | print(decodedResponse) 56 | // update our UI 57 | self.results = decodedResponse.items 58 | } 59 | 60 | // everything is good, so we can exit 61 | return 62 | } 63 | } 64 | 65 | // if we're still here it means there was a problem 66 | print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") 67 | }.resume() 68 | 69 | 70 | } 71 | 72 | } 73 | 74 | struct ContentView_Previews: PreviewProvider { 75 | static var previews: some View { 76 | ContentView() 77 | } 78 | } 79 | 80 | struct empSelect: View { 81 | let items: items 82 | var body: some View { 83 | NavigationLink(destination: EmpDetail(name: items.name, 84 | phone: items.phone, 85 | address: items.address, 86 | city: items.city, 87 | state: items.state, 88 | zip: items.zip)) { 89 | Text(String(items.id)) 90 | .foregroundColor(Color.black) 91 | .padding(.all, 8.0) 92 | .frame(width: 35.0) 93 | .overlay(RoundedRectangle(cornerRadius: 20) 94 | .stroke(Color.black, lineWidth: 3) 95 | ) 96 | VStack (alignment: .leading) { 97 | Text(items.name) 98 | Text(items.phone) 99 | .font(.system(size: 11)) 100 | .foregroundColor(Color.gray) 101 | } 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/EmpDetail.swift: -------------------------------------------------------------------------------- 1 | // 2 | // empDetail.swift 3 | // ords_iPhone 4 | // 5 | // Created by Brian Spendolini on 3/5/21. 6 | // 7 | 8 | import SwiftUI 9 | import MapKit 10 | import CoreLocation 11 | 12 | struct EmpDetail: View { 13 | 14 | func getLocation(from address: String, completion: @escaping (_ location: CLLocationCoordinate2D?)-> Void) { 15 | let geocoder = CLGeocoder() 16 | geocoder.geocodeAddressString(address) { (placemarks, error) in 17 | guard let placemarks = placemarks, 18 | let location = placemarks.first?.location?.coordinate else { 19 | completion(nil) 20 | return 21 | } 22 | 23 | completion(location) 24 | } 25 | } 26 | 27 | 28 | 29 | @State var location: CLLocationCoordinate2D? 30 | @State var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 30.16622932512246, longitude: -97.73921163282644), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)) 31 | 32 | var name: String 33 | var phone: String 34 | var address: String 35 | var city: String 36 | var state: String 37 | var zip: String 38 | 39 | var body: some View { 40 | VStack(alignment: .leading) { 41 | 42 | Text(name) 43 | .font(.title) 44 | 45 | Text(phone) 46 | .font(.subheadline) 47 | Divider() 48 | 49 | Text(address) 50 | .font(.headline) 51 | .lineLimit(50) 52 | Text(city) 53 | .font(.headline) 54 | .lineLimit(50) 55 | Text(state) 56 | .font(.headline) 57 | .lineLimit(50) 58 | Text(zip) 59 | .font(.headline) 60 | .lineLimit(50) 61 | Divider() 62 | Map(coordinateRegion: $region) 63 | }.padding().navigationBarTitle(Text(name), displayMode: .inline) 64 | .onAppear { 65 | self.getLocation(from: address + " " + 66 | city + " " + 67 | state + " " + 68 | zip) { coordinates in 69 | print(address + " " + 70 | city + " " + 71 | state + " " + 72 | zip) 73 | print(coordinates) // Print here 74 | self.location = coordinates // Assign to a local variable for further processing 75 | } 76 | } 77 | } 78 | 79 | struct EmpDetail_Previews: PreviewProvider { 80 | static var previews: some View { 81 | EmpDetail(name: "name", phone: "phone", address: "address", city: "city", state: "state", zip: "zip") 82 | } 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/ords_iPhone/ords_iPhone/ords_iPhoneApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ords_iPhoneApp.swift 3 | // ords_iPhone 4 | // 5 | // Created by Brian Spendolini on 3/5/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct ords_iPhoneApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/rest/xcode-iOS/setups/emps.sql: -------------------------------------------------------------------------------- 1 | # Create EMPS table for demo 2 | 3 | CREATE TABLE "GARY"."EMPS" 4 | ( "ID" NUMBER, 5 | "NAME" VARCHAR2(100), 6 | "PHONE" VARCHAR2(20), 7 | "ADDRESS" VARCHAR2(400), 8 | "CITY" VARCHAR2(200), 9 | "STATE" VARCHAR2(20), 10 | "ZIP" VARCHAR2(20) 11 | ); -------------------------------------------------------------------------------- /ords/Parameters/Example2.md: -------------------------------------------------------------------------------- 1 | # How to pass a value to the HTTP Response Header 2 | Instead of showing how to reference a value passed in via the HTTP Request Header, this will show how to assign a value to parameter included in the HTTP response header. 3 | 4 | HTTP Response Headers are not available for GET requests, so this example will be demonstrated via a POST handler. 5 | 6 | This will demonstrate how to: 7 | 8 | - Assign a value from the PL/SQL block to a parameter on the HTTP Response Header 9 | - Assign a value from the PL/SQL block to the Response Body itself 10 | 11 | *Note: the purpose of this example is not to deal with the response body specifically, but we show it briefly here as a convenience.* 12 | 13 | POST handlers are serviced by PL/SQL blocks. HTTP POST is generally used to add an object to a resource. This would be accomplished by running an INSERT statement. For this example, we are merely sending data back on the response header - it is not meant to be indicative of the typical POST handler. 14 | 15 | ![](parameter-header-response.png) 16 | 17 | ``` 18 | curl -X POST \ 19 | http://localhost:8080/ords/hr/parameters/headers \ 20 | -H 'cache-control: no-cache' 21 | ``` 22 | 23 | # And the response headers: 24 | 25 | access-control-allow-credentials →true 26 | access-control-allow-origin →chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo 27 | access-control-expose-headers →count, Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Vary 28 | content-type →application/json 29 | count →4 30 | date →Fri, 19 Jan 2018 20:16:48 GMT 31 | transfer-encoding →chunked 32 | vary →Origin 33 | 34 | Note that we passed back the number of records in the table (4) via the bind *:total*, which is mapped to the HTTP Response Header element, *count*. 35 | 36 | # And the response body: 37 | 38 | {"message":"There are 4 records in the parameters table."} 39 | 40 | Since we are already looking at a POST handler, you can see it's very easy to put together the RESPONSE body. 41 | 42 | Next Example: [Passing a value to the GET Handler code using URL Parameters](Example3.md). -------------------------------------------------------------------------------- /ords/Parameters/Example3.md: -------------------------------------------------------------------------------- 1 | # How to Pass a value to the GET Handler code using URL Parameters 2 | 3 | Instead of coding the parameter into the URI definition itself, this will show how to pass values via the URL, e.g. 4 | 5 | *http://localhost:8080/ords/hr/parameters/headers-classic?id=4* 6 | 7 | This is a very straightforward definition. You do not need to code the URI pattern in advance knowing what parameters you want to pass. 8 | 9 | In other words, the RESTful Service definition is not explicitly aware of the parameter, but you can reference these values in the GET handler SQL block. 10 | 11 | Note that this would not generally be considered a REST best practice. 12 | 13 | ![](url-parameter.png) 14 | 15 | 16 | ``` 17 | curl -X GET \ 18 | 'http://localhost:8080/ords/hr/parameters/headers-classic?id=4' \ 19 | -H 'cache-control: no-cache' \ 20 | ``` 21 | 22 | And the Response: 23 | 24 | { 25 | "items": [ 26 | { 27 | "id": 4, 28 | "words": "audios", 29 | "when": "2018-01-19T20:22:49Z", 30 | "age": 63 31 | } 32 | ], 33 | "hasMore": false, 34 | "limit": 25, 35 | "offset": 0, 36 | "count": 1, 37 | "links": [ 38 | { 39 | "rel": "self", 40 | "href": "http://localhost:8080/ords/hr/parameters/headers-classic?id=4" 41 | }, 42 | { 43 | "rel": "describedby", 44 | "href": "http://localhost:8080/ords/hr/metadata-catalog/parameters/item" 45 | }, 46 | { 47 | "rel": "first", 48 | "href": "http://localhost:8080/ords/hr/parameters/headers-classic?id=4" 49 | } 50 | ] 51 | } 52 | 53 | We asked for record '4' and were returned record '4.' Note you can pass as many parameters as you would like via the URL. URL encoding will be required if you need to send reserved characters, spaces, etc. 54 | 55 | Next Example: [Building one or more parameters into the URI](Example4.md). -------------------------------------------------------------------------------- /ords/Parameters/Example4.md: -------------------------------------------------------------------------------- 1 | # How to build one or more parameters into the URI 2 | 3 | As opposed to the previous example, we will now hard code the one or more parameters into the template pattern itself. 4 | 5 | The parameters do not need to be declared, as they are coming in via the request URI, and not the request header keys. 6 | 7 | ![](uri-parameters.png) 8 | 9 | For ORDS to recognize the requests, each template must be defined separately. 10 | 11 | **Scenario 1: Passing a single parameter** 12 | 13 | ``` 14 | curl -X GET \ 15 | http://localhost:8080/ords/hr/parameters/headers/3 \ 16 | -H 'cache-control: no-cache' \ 17 | ``` 18 | 19 | ORDS recognizes this route pattern and is able to navigate appropriate code block, returning the records whose ID=3. 20 | 21 | And the Response: 22 | 23 | { 24 | "items": [ 25 | { 26 | "id": 3, 27 | "words": "hola", 28 | "when": "2018-01-19T20:19:40Z", 29 | "age": 12 30 | } 31 | ], 32 | "hasMore": false, 33 | "limit": 25, 34 | "offset": 0, 35 | "count": 1, 36 | "links": [ 37 | { 38 | "rel": "self", 39 | "href": "http://localhost:8080/ords/hr/parameters/headers/3" 40 | }, 41 | { 42 | "rel": "describedby", 43 | "href": "http://localhost:8080/ords/hr/metadata-catalog/parameters/headers/item" 44 | }, 45 | { 46 | "rel": "first", 47 | "href": "http://localhost:8080/ords/hr/parameters/headers/3" 48 | } 49 | ] 50 | } 51 | 52 | 53 | 54 | **Scenario 2: Passing 2 parameters** 55 | 56 | ``` 57 | curl -X GET \ 58 | http://localhost:8080/ords/hr/parameters/headers/audios/63 \ 59 | -H 'cache-control: no-cache' \ 60 | ``` 61 | 62 | 63 | ORDS recognizes this route pattern and is able to navigate appropriate code block, returning the records whose words = 'audios' and age = 63. 64 | 65 | And the Response: 66 | 67 | { 68 | "items": [ 69 | { 70 | "id": 4, 71 | "words": "audios", 72 | "when": "2018-01-19T20:22:49Z", 73 | "age": 63 74 | } 75 | ], 76 | "hasMore": false, 77 | "limit": 25, 78 | "offset": 0, 79 | "count": 1, 80 | "links": [ 81 | { 82 | "rel": "self", 83 | "href": "http://localhost:8080/ords/hr/parameters/headers/audios/63" 84 | }, 85 | { 86 | "rel": "describedby", 87 | "href": "http://localhost:8080/ords/hr/metadata-catalog/parameters/headers/audios/item" 88 | }, 89 | { 90 | "rel": "first", 91 | "href": "http://localhost:8080/ords/hr/parameters/headers/audios/63" 92 | } 93 | ] 94 | } 95 | 96 | ## ORDS Also supports /{id}/{id2} notation ## 97 | However, we recommend the more modern /:id/:id2 nation and do not guarantee continuing support. -------------------------------------------------------------------------------- /ords/Parameters/READme.md: -------------------------------------------------------------------------------- 1 | # ords-demo-parameters 2 | Build scripts to demonstrate working with parameters in your Oracle REST Data Services (ORDS) RESTful Services. 3 | 4 | This will demonstrate how to: 5 | 6 | - Read a value in your GET handler SQL block from the request header 7 | - Return a value via HTTP Header and Response Body via your POST handler anonymous block 8 | - Read a value in your GET handler SQL block from the URI?var=value 9 | - Read a value in your GET handler SQL block from the URI/:value or /:value1/:value2 10 | 11 | 12 | 13 | 14 | # Prerequisites 15 | 16 | You will need at least a browser to work with the simple GET examples. You will also need a REST client such as Postman or cURL. 17 | 18 | Download from OTN: ORDS & Oracle SQL Developer 19 | 20 | Required: [Download ORDS](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html) 21 | 22 | Required: [Download SQLDev](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) 23 | 24 | Required: Install ORDS, configure for an Oracle Database (11gR2 or higher), REST enable a schema. 25 | 26 | # Table of Contents 27 | 28 | - Installation and Example 1 29 | - [Example 2: passing a value to the HTTP Header Response (and Body)](Example2.md) 30 | - [Example 3: passing a value to the GET Handler code using URL Parameters](Example3.md) 31 | - [Example 4: building one or more parameters into the URI](Example4.md) 32 | 33 | 34 | 35 | # 'Installation' and Example 1 36 | 37 | Using SQL Developer, open the two .SQL files in this project directory, and execute on a connection to the REST enabled schema. 38 | 39 | The parameters-rest.sql file is commented to show how the ORDS PL/SQL API builds the Module, Templates, and Handlers. 40 | 41 | After successful execution, you will have a PARAMETERS table, and a PARAMETERS RESTful Services Module. 42 | 43 | ![](rest-tree.png) 44 | 45 | # Scenario 1: Getting a record from the PARAMETERS table by passing an ID via the HTTP GET Header 46 | 47 | The URLs shown assume that ORDS is running on the local machine via port 8080, and that the REST enabled schema is HR. 48 | 49 | Example 1: Pulling a value off the request header. 50 | 51 | ``` 52 | curl -X GET \ 53 | http://localhost:8080/ords/hr/parameters/headers \ 54 | -H 'cache-control: no-cache' \ 55 | -H 'id: 2' 56 | ``` 57 | 58 | *For example, how can we reference the value of ID passed via cURL in the database code?* 59 | 60 | ![](parameter-name-bind.png) 61 | 62 | In the associated GET handler code block, as shown in the image above, the value from the HTTP header is declared as part of the RESTful Service in the Parameters page. The 'name' is the HTTP request header Key name. The Bind Parameter value is how the value will be references in the SQL statement. It is being declared as an INTEGER so it will be treated in the query statement as a number. 63 | 64 | Running the request with a ID value of 2, the response from ORDS will be similar to the following: 65 | 66 | { 67 | "items": [ 68 | { 69 | "id": 2, 70 | "words": "goodbye", 71 | "when": "2018-01-19T20:17:32Z", 72 | "age": 5 73 | } 74 | ], 75 | "hasMore": false, 76 | "limit": 25, 77 | "offset": 0, 78 | "count": 1, 79 | "links": [ 80 | { 81 | "rel": "self", 82 | "href": "http://localhost:8080/ords/hr/parameters/headers" 83 | }, 84 | { 85 | "rel": "edit", 86 | "href": "http://localhost:8080/ords/hr/parameters/headers" 87 | }, 88 | { 89 | "rel": "describedby", 90 | "href": "http://localhost:8080/ords/hr/metadata-catalog/parameters/item" 91 | }, 92 | { 93 | "rel": "first", 94 | "href": "http://localhost:8080/ords/hr/parameters/headers" 95 | } 96 | ] 97 | } 98 | 99 | Next Example: [Passing a value to the HTTP Header Response (and Body)](Example2.md). -------------------------------------------------------------------------------- /ords/Parameters/parameter-header-response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/Parameters/parameter-header-response.png -------------------------------------------------------------------------------- /ords/Parameters/parameter-name-bind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/Parameters/parameter-name-bind.png -------------------------------------------------------------------------------- /ords/Parameters/parameters_table.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------- 2 | -- DDL for Table PARAMETERS 3 | -------------------------------------------------------- 4 | CREATE TABLE parameters ( 5 | id NUMBER(*,0), 6 | words VARCHAR2(256 BYTE), 7 | when DATE, 8 | age NUMBER(*,0) 9 | ); 10 | 11 | REM INSERTING into PARAMETERS 12 | 13 | SET DEFINE OFF; 14 | 15 | INSERT INTO parameters ( 16 | id, 17 | words, 18 | when, 19 | age 20 | ) VALUES ( 21 | 1, 22 | 'hello', 23 | TO_DATE('19-JAN-18','DD-MON-RR'), 24 | 25 25 | ); 26 | 27 | INSERT INTO parameters ( 28 | id, 29 | words, 30 | when, 31 | age 32 | ) VALUES ( 33 | 2, 34 | 'goodbye', 35 | TO_DATE('19-JAN-18','DD-MON-RR'), 36 | 5 37 | ); 38 | 39 | INSERT INTO parameters ( 40 | id, 41 | words, 42 | when, 43 | age 44 | ) VALUES ( 45 | 3, 46 | 'hola', 47 | TO_DATE('19-JAN-18','DD-MON-RR'), 48 | 12 49 | ); 50 | 51 | INSERT INTO parameters ( 52 | id, 53 | words, 54 | when, 55 | age 56 | ) VALUES ( 57 | 4, 58 | 'audios', 59 | TO_DATE('19-JAN-18','DD-MON-RR'), 60 | 63 61 | ); -------------------------------------------------------------------------------- /ords/Parameters/rest-tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/Parameters/rest-tree.png -------------------------------------------------------------------------------- /ords/Parameters/uri-parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/Parameters/uri-parameters.png -------------------------------------------------------------------------------- /ords/Parameters/url-parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/Parameters/url-parameter.png -------------------------------------------------------------------------------- /ords/READme.md: -------------------------------------------------------------------------------- 1 | # ords-sql-examples 2 | Scripts that demonstrate RESTful Services with Oracle REST Data Services (ORDS). 3 | 4 | We also have a set of examples for the REST Enabled SQL feature [here](https://github.com/oracle/oracle-db-tools/tree/master/ords/rest-sql). 5 | 6 | # Prerequisites 7 | 8 | You will need at least a browser to work with the simple GET examples. You will also need a REST client such as Postman or cURL. 9 | 10 | Download from OTN: ORDS & Oracle SQL Developer 11 | 12 | Required: [Download ORDS](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html) 13 | 14 | Required: [Download SQLDev](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) 15 | 16 | Required: Install ORDS, configure for an Oracle Database (11gR2 or higher), REST enable a schema. 17 | 18 | # REST Enabling a Schema 19 | 20 | RESTful Services are defined in the schema from which the services will run. For example, a service mapped to /ords/hr/ will run as the HR user, therefore inheriting the privileges defined for that Oracle user account. 21 | 22 | This code sample will REST enable the HR schema, therefore allowing RESTful Services to be defined in the HR schema, and for those said services to be executed as the HR user. 23 | 24 | 25 | 26 | BEGIN 27 | ORDS.ENABLE_SCHEMA(p_enabled => TRUE, 28 | p_schema => 'HR', 29 | p_url_mapping_type => 'BASE_PATH', 30 | p_url_mapping_pattern => 'hr', 31 | p_auto_rest_auth => FALSE); 32 | 33 | commit; 34 | END; 35 | 36 | To access services on this REST enabled schema, you would use this URI pattern to get started: 37 | 38 | *https://host:port/ords/hr* -- where 'hr' is the `p_url_mapping_pattern` value. 39 | 40 | To access a list of the available services on a schema, use the /metadata-catalog/ endpoint: 41 | 42 | *https://host:port:/ords/hr/metadata-catalog/* 43 | 44 | This endpoint returns a JSON document. Each RESTful Services module also includes a */open-api-catalog/* endpoint which supports the Open API 2.0 (Swagger) Spec. 45 | 46 | ![](swagger.png) 47 | 48 | 49 | 50 | 51 | # On Security 52 | 53 | For simplicity, many of the examples here are presented unsecured. This is not recommended for production deployments. ORDS supports many authentication schemes, including OAuth2 and first party auth, and we plan on delivering example scenarios to showcase securing your services specifically. -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/files/inline-code-example.txt: -------------------------------------------------------------------------------- 1 | Dummy file to demonstrate code in an included text file. -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/files/sample-arch-image.txt: -------------------------------------------------------------------------------- 1 | [This is a sample image description file.] 2 | 3 | This illustration shows the process to integrate Oracle IoT Cloud Service with Oracle Service Cloud by using the service's application integration feature. 4 | The sequence of flow is depicted as follows: 5 | 1. The message flows from a device to Oracle IoT Cloud Service. 6 | 2. Oracle IoT Cloud Service uses its application integration feature to connect with Oracle Integration Cloud Service, and sends the messages that fulfill the Exploration filter (temperature > 55). 7 | 3. Oracle Integration Cloud Service verifies, if a message for a device in Oracle IoT Cloud Service wasn't already created as an incident in Oracle Service Cloud, then sends the incident to Oracle Service Cloud. 8 | 4. Oracle Service Cloud creates an incident for a device. 9 | 10 | In the image, the Organization part of the Oracle Service Cloud configuration is bordered. 11 | -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/files/sample-image-1.txt: -------------------------------------------------------------------------------- 1 | [This is a sample image description file.] 2 | 3 | This images shows the Service Details page for an Storage Cloud service instance. In the top of image there is an icon representing Oracle Storage Cloud and a button labeled Open Service Console. 4 | Below the icon are four tabs: Overview, Billing Metrics, Business Metrics and Documents. The Overview tab is selected. 5 | In the body of the image is the overview information for this instance of Oracle Storage Cloud Service, including Plan: Oracle Storage Cloud Service, Data Jurisdiction: EMEA Commercial 2 - Amsterdam, Service Start Date: 11-Aug-2016, Identity Domain Name: paas116, Service End Date: 7-May-2019, Status: Active, Subscription ID: 538835520, Domain SFTP Host & Port: stftp.em2.cloud.oracle.com:22, Service Instance ID: 538835587, Domain SFTP User Name: em230803, Customer Account: OraclePaaS (GB), REST Endpoint: https://paas116.storage.oracle (circled). -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.1.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.10.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.11.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.12.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.13.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.14.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.15.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.16.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.17.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.18.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.19.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.2.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.20.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.21.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.22.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.23.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.24.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.25.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.26.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.27.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.28.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.29.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.3.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.30.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.31.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.32.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.4.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.5.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.6.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.7.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.8.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/1.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/1.9.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_1.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_2.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_3.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_4.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_5.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_6.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_7.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_8.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_begin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_begin.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_more.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/32_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/32_next.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/obe_tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/obe_tag.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/oracle_doc_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/oracle_doc_logo.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/sample-arch-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/sample-arch-image.png -------------------------------------------------------------------------------- /ords/oow19_lab/ORDS_SQLWeb/html/img/sample-image-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/oow19_lab/ORDS_SQLWeb/html/img/sample-image-1.png -------------------------------------------------------------------------------- /ords/rest-sql/curl-2-sqls.sh: -------------------------------------------------------------------------------- 1 | ## SQL 2 sql statements 2 | curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/sql" \ 4 | -u HR:oracle \ 5 | -d $'select count(1) abc from user_objects; 6 | 7 | select * from dual;' 8 | 9 | -------------------------------------------------------------------------------- /ords/rest-sql/curl-ddl.sh: -------------------------------------------------------------------------------- 1 | ## SQL-EMP-DDL 2 | curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/sql" \ 4 | -u HR:oracle \ 5 | -d $'set ddl SEGMENT_ATTRIBUTES off 6 | set ddl storage off 7 | set ddl pretty on 8 | ddl emp' 9 | 10 | -------------------------------------------------------------------------------- /ords/rest-sql/curl-dual.sh: -------------------------------------------------------------------------------- 1 | ## SQL 2 sql statements 2 | time curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/sql" \ 4 | -u HR:oracle \ 5 | -d $'select * from dual;' 6 | 7 | -------------------------------------------------------------------------------- /ords/rest-sql/curl-pagination.sh: -------------------------------------------------------------------------------- 1 | ## SQL-Pagination 2 | curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/json" \ 4 | -u HR:oracle \ 5 | -d $'{ 6 | "statementText": "select object_name from all_objects where ? = ?", 7 | "binds": [ 8 | { 9 | "index": 1, 10 | "data_type": "NUMBER", 11 | "value": 20 12 | }, 13 | { 14 | "index": 2, 15 | "data_type": "NUMBER", 16 | "value": 20 17 | } 18 | ], 19 | "$asof": { 20 | "$scn": "1273919" 21 | }, 22 | "offset": 25, 23 | "limit": 5 24 | }' 25 | 26 | -------------------------------------------------------------------------------- /ords/rest-sql/curl-restricted-cmds.sh: -------------------------------------------------------------------------------- 1 | ## SQL-alias-restricted 2 | curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/sql" \ 4 | -u HR:oracle \ 5 | -d $'spool xyz.log 6 | alias' 7 | 8 | -------------------------------------------------------------------------------- /ords/rest-sql/curl-script.sh: -------------------------------------------------------------------------------- 1 | ## SQL Script 2 | curl -X "POST" "http://localhost:9090/ords/hr/_/sql" \ 3 | -H "Content-Type: application/sql" \ 4 | -u HR:oracle \ 5 | -d $'create table klrice_test( 6 | id number, 7 | name varchar2(200) 8 | ); 9 | insert into klrice_test values(1,\'hi\'); 10 | insert into klrice_test values(2,\'hi again\'); 11 | insert into klrice_test values(3,\'cya\'); 12 | select * from klrice_test; 13 | rollback; 14 | 15 | select * from klrice_test; 16 | drop table klrice_test;' 17 | 18 | -------------------------------------------------------------------------------- /ords/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/ords/swagger.png -------------------------------------------------------------------------------- /sbom_generation.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. 2 | 3 | # This OCI DevOps build specification file [1] generates a Software Bill of Materials (SBOM) of the repository. 4 | # The file is needed to run checks for third-party vulnerabilities and business approval according to Oracle’s GitHub policies. 5 | # [1] https://docs.oracle.com/en-us/iaas/Content/devops/using/build_specs.htm 6 | 7 | version: 0.1 8 | component: build 9 | timeoutInSeconds: 1000 10 | shell: bash 11 | 12 | steps: 13 | - type: Command 14 | name: "Install dependencies & cyclonedx-node-npm package" 15 | command: | 16 | npm install && npm install --save-dev @cyclonedx/cyclonedx-npm 17 | - type: Command 18 | name: "Run cyclonedx-node-npm package" 19 | command: | 20 | # For more details, visit https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/README.md 21 | npx @cyclonedx/cyclonedx-npm --omit dev --output-format JSON --output-file artifactSBOM.json --spec-version 1.4 22 | outputArtifacts: 23 | - name: artifactSBOM 24 | type: BINARY 25 | location: ${OCI_PRIMARY_SOURCE_DIR}/artifactSBOM.json 26 | -------------------------------------------------------------------------------- /sqlcl/EDIT.md: -------------------------------------------------------------------------------- 1 | **Oracle SQLcl** 2 | *Inline Editor* 3 | 4 | **What is it?** 5 | SQLcl offers an inline editor. The SQLcl command prompt is used to submit commands, queries, and scripts to be executed. 6 | 7 | The input can be edited, inline, i.e. without requiring sending the buffer contents to a 3rd party editor such as notepad or vi. 8 | 9 | The DEFINE variable _EDITOR determines which editor to use in SQLcl when the 'edit' command is issued. To set it to the inline editor, use a value of "inline" To see the list of current DEFINEs in SQLcl, use "show defines" 10 | 11 | ![default external editor](images/inline2.png "external editor") 12 | 13 | 14 | *Usage:* 15 | 16 | The inline editor is always available regardless of the current DEFINE _EDITOR value. To invoke it, simply use the keyboard arrow keys. 17 | 18 | The cursor can be moved within the contents of the buffer by either using the arrow keys or with a series of ctrl key sequences. 19 | 20 | To change the first characters of the current line, use the left arrow to move the cursor to the desired cursor position. New characters are inserted at the current cursor position. 21 | 22 | To change the current line position, use the up or down arrow key to move up or down a line. The current line in the buffer is marked with a '*' character in the editor gutter. 23 | 24 | ![editor current line](images/inline1.png "current line") 25 | 26 | When moving a line up or down in the editor, be sure to first move at least one cursor position left. This will put the the editor in edit mode and prevent the up or down arrow key from being interpreted as a request to replace the buffer contents with the SQL History contents. 27 | 28 | Invoking the inline editor will also 'jump' the buffer contents to the bottom of your screen. This gives SQLcl a known amount of workspace in your shell window to facilitate the display of however many lines are in your buffer. 29 | 30 | **Ctrl Key Navigation** 31 | 32 | Ctrl + R - Immediately run the current buffer 33 | 34 | Ctrl + W - Go to the top of the buffer (first line, first character) 35 | 36 | Ctrl + S - Go to the bottom of the buffer (last line, last character) 37 | 38 | Ctrl + A - Go to the start of the current line 39 | 40 | Ctrl + E - Go to the end of the current line 41 | 42 | -------------------------------------------------------------------------------- /sqlcl/FORMATTING.md: -------------------------------------------------------------------------------- 1 | **Oracle SQLcl** 2 | *SET System Variables - SQLFORMAT* 3 | 4 | **What is it?** 5 | SQLFORMAT sets the query response format. The default is unformatted query results via the NULL setting. 6 | 7 | *Usage:* 8 | 9 | SET SQLFORMAT { csv, delimited, html,xml,json,ansiconsole,insert,loader,fixed,default} 10 | 11 | The available SQLFORMAT names are case-sensitive. 12 | 13 | Query formatting can also be achieved at the statement level via a comment, e.g. 14 | 15 | Method 1: 16 | 17 | *select /\*csv\*/ \* from hr.employees;* 18 | 19 | Method 2: 20 | 21 | *set sqlformat csv* 22 | 23 | *select \* from hr.employees;* 24 | 25 | Both will return the data in the hr.employees table as comma separated values (CSV). 26 | 27 | ![sqlformat csv output](images/csv.png "csv output") 28 | 29 | **Additional Notes** 30 | 31 | Delimited - The delimiter character and string enclosures can be defined as additional arguments, e.g. 32 | 33 | set SQLFORMAT delimited ; " " -- where the first argument sets the delimiter character, the second defines the left string enclosure, and the third defines the right string enclosure. 34 | 35 | Example: 36 | 37 | ~~~ 38 | HR@orcl🆒 >set sqlformat delimited || ' ' 39 | HR@orcl🆒 >select 1,2,3, 'abc' from dual; 40 | '1'||'2'||'3'||''ABC'' 41 | 1||2||3||'abc' 42 | ~~~ 43 | 44 | Ansiconsole - This format has each page of SQL statement results measured and best-fit based on the size of the editor window. In addition, you can use escape sequences to decorate the text and format numbers. 45 | 46 | Decorating text, e.g. coloring, bolding, blinking, italicizing, etc, can be done via the Jansi project on GitHub. A full set of Docs and exmples can be found [here](https://github.com/fusesource/jansi/blob/master/jansi/src/main/java/org/fusesource/jansi/Ansi.java). 47 | 48 | Example: 49 | 50 | ~~~ 51 | set sqlformat ansiconsole 52 | with ts_details as 53 | ( 54 | select rpad(tablespace_name,30, ' ')||' '||lpad(floor(used_percent), 3, ' ') as ts_line, 55 | used_percent 56 | from dba_tablespace_usage_metrics 57 | ) 58 | select 59 | case 60 | when used_percent > 70 then '@|bg_red '||ts_line||'|@' 61 | when used_percent < 1 then '@|bg_green '||ts_line||'|@' 62 | else '@|bg_yellow '||ts_line||'|@' 63 | end as ts_usage_percentage 64 | from ts_details 65 | / 66 | ~~~ 67 | ![Traffic Light Example from Tom](images/traffic_light.png "Traffic Light Example") 68 | 69 | 70 | 71 | Formatting numbers is accomplished via the Java Class DecimalFormat. A full set of Docs and examples can be found [here](https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html). 72 | 73 | Example: 74 | 75 | ~~~ 76 | HR@orcl🆒 >set sqlformat ansiconsole ##.##E00 77 | HR@orcl🆒 >select 1234567890 from dual; 78 | 79 | 1234567890 80 | ----------------- 81 | 12.35E08 82 | ~~~ 83 | 84 | -------------------------------------------------------------------------------- /sqlcl/README.md: -------------------------------------------------------------------------------- 1 | # SQLcl 2 | 3 | ![SQLcl logo](images/sql-command-line-200.png) 4 | 5 | SQLcl is the core scripting library for Oracle SQL Developer. That library has been factored out and wrappered with a command line to bring SQLcl. 6 | 7 | # SQLcl Download 8 | 9 | The tool can be downloaded from Oracle.com here: [http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) 10 | 11 | # Scripting 12 | 13 | SQLcl scripting is based on Java's [JSR-223](https://jcp.org/aboutJava/communityprocess/final/jsr223/index.html) which allows scripting languages to be executed from the Java VM. There are a number of languages that can be plugged in with the NashHorn Javascript engine being included in Java. A list of languages can be found [here](https://en.wikipedia.org/wiki/List_of_JVM_languages) 14 | 15 | More Here: [Scripting](SCRIPTING.md) 16 | 17 | # Java 18 | 19 | SQLcl is written in java and those java classes can also be leveraged directly. This can facilite running sql scripts from existing java programs. There are a lot of features that can be leveraged and this will be exapanding in the /java/ folder. 20 | 21 | More Here: [Java](java/README.md) 22 | -------------------------------------------------------------------------------- /sqlcl/SCRIPTING.md: -------------------------------------------------------------------------------- 1 | # SQLcl - Scripting 2 | 3 | ![SQLcl logo](images/sql-command-line-200.png) 4 | 5 | 6 | ## What is it? 7 | 8 | SQLcl scripting is based on Java's [JSR-223](https://jcp.org/aboutJava/communityprocess/final/jsr223/index.html) which allows scripting languages to be executed from the Java VM. There are a number of languages that can be plugged in with the NashHorn Javascript engine being included in Java. A list of languages can be found [here](https://en.wikipedia.org/wiki/List_of_JVM_languages) 9 | 10 | The addition of client side scripting will allow control flow in the sql scripts themselves. It also allow for things like file access, greater control on host commands, leverage various javascript libraries, and the ability to leverage java. 11 | 12 | ## Globals 13 | 14 | There are a few globals pushed into the scripting engine for use. 15 | 16 | **args** -This is a simple array of the arguments passed along 17 | 18 | Example: 19 | 20 | ~~~ 21 | for(var arg in args) { 22 | ctx.write(arg + ":" + args[arg]); 23 | ctx.write("\n"); 24 | } 25 | ~~~ 26 | 27 | **sqlcl** - This is SQLCL itself 28 | 29 | ~~~ 30 | setStmt() 31 | This can be a single statement, an entire script of stuff, or any sqlcl command such as "@numbers.sql" 32 | ~~~ 33 | 34 | ~~~ 35 | run() 36 | Runs whatever is set via the setStmt function 37 | ~~~ 38 | 39 | Example: 40 | 41 | ~~~ 42 | /* Run any amount of command in the sqlcl prompt */ 43 | sqlcl.setStmt("select something from somewhere; @myscript \n begin null;end;"); 44 | 45 | sqlcl.run(); 46 | ~~~ 47 | 48 | **ctx** ( this has tons of methods but this is the single most important ) 49 | 50 | ~~~ 51 | write() 52 | ~~~ 53 | Example: 54 | 55 | ~~~ 56 | ctx.write('Hello World'); 57 | ~~~ 58 | ~~~ 59 | cloneCLIConnection(); 60 | ~~~ 61 | Example: 62 | 63 | ~~~ 64 | var JDBCConnection=ctx.cloneCLIConnection(); 65 | ~~~ 66 | 67 | **util** ( again tons of methods ) 68 | 69 | ~~~ 70 | execute(,binds) 71 | executes whatever is passed in with a boolean return for success/failure 72 | ~~~ 73 | ~~~ 74 | executeReturnOneCol(,binds) 75 | executes and returns the first row , first column 76 | ~~~ 77 | 78 | ~~~ 79 | executeReturnListofList(,binds) 80 | executes and returns an array(rows) of arrays(row). 81 | ~~~ 82 | ~~~ 83 | executeReturnList(,binds) 84 | execute and returns and array ( rows ) of objects ( row ) 85 | ~~~ 86 | ~~~ 87 | getLastException() 88 | returns the sql exeception from the executeXYZ functions 89 | ~~~ 90 | 91 | Examples: [sql.js](https://github.com/oracle/Oracle_DB_Tools/blob/master/sqlcl/examples/sql.js) 92 | 93 | ### Helper Functions 94 | 95 | While JSR-223 is great for adding javascript capabilities, knowledge of java is required for more advanced usage. Some of the more commonly needed functions will be provided in [helper.js](https://github.com/oracle/Oracle_DB_Tools/blob/master/sqlcl/lib/helpers.js). The .js file itself contains the descriptions of the functions. This will expand greatly as the examples and requests for examples grow. 96 | 97 | 98 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/datamove.sql: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | @@setup 14 | @@precheck 15 | @@dpexp 16 | @@dpxfer 17 | @@dpimp 18 | @@postcheck 19 | @@teardown 20 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/dpxfer.sql: -------------------------------------------------------------------------------- 1 | -- dpxfer.sql 2 | /* 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | */ 13 | 14 | -- transfer a file to object storage 15 | SET ECHO OFF 16 | SET SERVEROUTPUT ON 17 | SET ESCAPE OFF 18 | SET VERIFY ON 19 | prompt dpxfer starting ... 20 | 21 | cs oci &dm_oci_profile 22 | cs &dm_oci_bucket 23 | cs put &dm_data_pump_path/&dm_data_pump_log /o/&dm_data_pump_log 24 | cs put &dm_data_pump_path/&dm_data_pump_file /o/&dm_data_pump_file 25 | 26 | prompt dpxfer exiting 27 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/example.log: -------------------------------------------------------------------------------- 1 | D:\work\sqlcl-21.2.1.195.1252\bin>sql /nolog 2 | 3 | 4 | SQLcl: Release 21.2 Production on Fri Jul 23 17:06:30 2021 5 | 6 | Copyright (c) 1982, 2021, Oracle. All rights reserved. 7 | 8 | SQL> cd datamove-schema 9 | SQL> @@datamove 10 | Starting setup 11 | Exiting setup 12 | Starting precheck 13 | Ending precheck 14 | dpexp starting ... 15 | Password? (**********?) ****** 16 | Connected. 17 | Calculating data pump path and file name(s)... 18 | 19 | DIRECTORY_PATH 20 | -------------------------------------------------------------------------------- 21 | D:\app\bjeff\product\18.0.0\admin\xe\dpdump\/5460E3B4980F4EE0B5ECA9390928E66D 22 | 23 | 24 | DPFIL 25 | ------ 26 | HR.DMP 27 | 28 | 29 | DPLOG 30 | ---------- 31 | HR-EXP.LOG 32 | 33 | Exporting schema HR ... 34 | JOB_NAME: EXP_SD_1522 35 | DataPump Export Status: 'COMPLETED' 36 | 37 | 38 | PL/SQL procedure successfully completed. 39 | 40 | Disconnected from Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production 41 | Version 18.4.0.0.0 42 | dpexp exiting 43 | dpxfer starting ... 44 | DBMS_CLOUD Credential: Not Set 45 | OCI Profile: freedb 46 | Transfer Method: oci 47 | Cloud Storage URI: Not Set 48 | DBMS_CLOUD Credential: Not Set 49 | OCI Profile: freedb 50 | Transfer Method: oci 51 | URI as specified: https://objectstorage.us-phoenix-1.oraclecloud.com/n/oraclefreedb/b/transfer 52 | Put D:\app\bjeff\product\18.0.0\admin\xe\dpdump\/5460E3B4980F4EE0B5ECA9390928E66D/HR-EXP.LOG copied to https://objectstorage.us-phoenix-1.oraclecloud.com/n/oraclefreedb/b/transfer/o/HR-EXP.LOG 53 | Put D:\app\bjeff\product\18.0.0\admin\xe\dpdump\/5460E3B4980F4EE0B5ECA9390928E66D/HR.DMP copied to https://objectstorage.us-phoenix-1.oraclecloud.com/n/oraclefreedb/b/transfer/o/HR.DMP 54 | dpxfer exiting 55 | dpimp starting ... 56 | Password? (**********?) ************ 57 | Connected. 58 | Importing schema DM_SCHEMA ... 59 | credential = SWIFTCRED2 60 | JOB_NAME: IMP_SD_444 61 | DataPump Import Status: 'COMPLETED' 62 | 63 | 64 | PL/SQL procedure successfully completed. 65 | 66 | Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production 67 | Version 19.5.0.0.0 68 | dpimp exiting 69 | Starting postcheck 70 | Ending postcheck 71 | Starting teardown 72 | Ending teardown 73 | SQL> -------------------------------------------------------------------------------- /sqlcl/datamove-schema/postcheck.sql: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | prompt Starting postcheck 14 | -- Placeholder for any post operation checking we may want to do 15 | prompt Ending postcheck 16 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/precheck.sql: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | prompt Starting precheck 14 | -- Placeholder for any pre-flight checking we may want to do 15 | prompt Ending precheck 16 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/readme.md: -------------------------------------------------------------------------------- 1 | # datamove-schema scripts 2 | 3 | A set of scripts to datapump a schema from a local database to an ADW cloud database. 4 | 5 | *Tested on Oracle XE 18c and Oracle Autonomous Data Warehouse* 6 | 7 | ## Typical Usage: 8 | * edit dms-setup.sql to supply required information 9 | * SQL> cd \ 10 | * SQL> @@datamove 11 | 12 | ## The scripts 13 | * @@datamove - Controller script that runs the following in sequence 14 | * @@setup - Define required variables for the run 15 | * @@precheck - Perform preflight checks (TODO) 16 | * @@dpexp - Perform data pump export on local database 17 | * @@dpxfer - Transfer data pump files to object storage 18 | * @@dpimp - Import data pump from object storage to autonomous cloud db 19 | * @@postcheck - Perform post run checks 20 | * @@teardown - Undefine used 21 | 22 | ## License 23 | This project is licensed under the terms of the MIT license. 24 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/setup.sql: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | prompt Starting setup 14 | 15 | -- This is a script to define variables for datamove 16 | -- Edit this script to set variables as required 17 | -- N.B: DO NOT RELY on auto uppercase. Many of these values get passed as parameters to dbms_datapump which require an exact match. 18 | 19 | -- SOURCE INFO (local with accessable data pump dir/path) 20 | -- ====================================================== 21 | -- The source connect string. The password will be prompted for if not entered. 22 | define dm_source = 'sys@localhost:1521/XEPDB1 as SYSDBA'; 23 | -- The schema to export 24 | define dm_schema_exp = 'HR'; 25 | -- The datapump directory for export (Path MUST be accessible to running sqlcl) 26 | -- FOR FUTURE EXPANSION the same value is used on both exp & imp so need to split if we really want to allow user to specify 27 | define dm_data_pump_dir = 'DATA_PUMP_DIR'; 28 | 29 | --pre declaration for calculated data pump path / files - calculated in dms-dpexp 30 | define dm_data_pump_path = 'uninitialized'; -- Pulled from all_directories based on data pump dir 31 | define dm_data_pump_file = 'uninitialized'; -- will be .DMP 32 | define dm_data_pump_log = 'uninitialized'; -- will be -EXP.LOG 33 | 34 | -- TRANSFER INFO FOR OBJECT STORAGE USING OCI 35 | -- ========================================== 36 | -- The oci profile for uploading the datapump files to object storage 37 | define dm_oci_profile = 'freedb'; 38 | -- The url to an object storage bucket, file(s) will be replaced if they exist 39 | define dm_oci_bucket = 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/oraclefreedb/b/transfer'; 40 | 41 | 42 | -- TARGET INFO (autonomous connection and dbms_cloud credential for object storage) 43 | -- ================================================================================ 44 | -- The path for the wallet zip file 45 | define dm_cloud_config = 'd:\work\Wallet_ADW20210622.zip'; 46 | -- DBMS_CLOUD credential with permissions to object storage (exact match - no auto uppercase - make sure you do) 47 | define dm_credential = 'SWIFTCRED2'; -- TODO: Swift credential!? Why doesn't oci one work (v19 adw maybe 21 is only one that does that?) 48 | -- The target database connect string. The password will be prompted for if not entered. 49 | define dm_target = 'ADMIN@ADW20210622_high'; 50 | -- The target schema 51 | define dm_schema_imp = 'DM_SCHEMA'; 52 | 53 | prompt Exiting setup 54 | -------------------------------------------------------------------------------- /sqlcl/datamove-schema/teardown.sql: -------------------------------------------------------------------------------- 1 | -- teardown.sql 2 | /* 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | */ 13 | 14 | -- clear defined variables 15 | prompt Starting teardown 16 | 17 | -- source 18 | undefine dm_source; 19 | undefine dm_schema_exp; 20 | undefine dm_data_pump_dir; 21 | undefine dm_data_pump_file; 22 | undefine dm_data_pump_path; 23 | undefine dm_data_pump_file; 24 | undefine dm_data_pump_log; 25 | 26 | --transfer 27 | undefine dm_oci_profile; 28 | undefine dm_oci_bucket; 29 | 30 | --target 31 | undefine dm_cloud_config 32 | undefine dm_credential; 33 | undefine dm_target; 34 | undefine dm_schema_imp; 35 | 36 | prompt Ending teardown 37 | -------------------------------------------------------------------------------- /sqlcl/examples/SetSchema.js: -------------------------------------------------------------------------------- 1 | // 2 | // Simple command to add "s " which issues 3 | // alter session set current_schema = 4 | // 5 | // 6 | // SQLCL's Command Registry 7 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 8 | 9 | // CommandListener for creating any new command 10 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 11 | 12 | 13 | // Broke the .js out from the Java.extend to be easier to read 14 | var cmd = {}; 15 | 16 | // Called to attempt to handle any command 17 | cmd.handle = function (conn,ctx,cmd) { 18 | var subCmd = cmd.getSql().trim().split(" ") 19 | if ( subCmd[0].equalsIgnoreCase("s")){ 20 | sqlcl.setStmt('alter session set current_schema = ' + subCmd[1]); 21 | sqlcl.run(); 22 | 23 | return true; 24 | } 25 | } 26 | // fired before ANY command 27 | cmd.begin = function (conn,ctx,cmd) {} 28 | 29 | // fired after ANY Command 30 | cmd.end = function (conn,ctx,cmd) {} 31 | 32 | // Actual Extend of the Java CommandListener 33 | 34 | var SetSchema = Java.extend(CommandListener, { 35 | handleEvent: cmd.handle , 36 | beginEvent: cmd.begin , 37 | endEvent: cmd.end 38 | }); 39 | 40 | // Registering the new Command 41 | CommandRegistry.addForAllStmtsListener(SetSchema.class); 42 | -------------------------------------------------------------------------------- /sqlcl/examples/apx.js: -------------------------------------------------------------------------------- 1 | function processApex(ctx,conn,subCmd){ 2 | if ( subCmd.length > 1 ) { 3 | try { 4 | switch (subCmd[1]) { 5 | case "export": 6 | exportApp(conn,subCmd[2]) 7 | break; 8 | case "log": 9 | runReport("SELECT workspace, application_id,application_name, page_Views, total_elapsed_time,average_elapsed_time,minimum_elapsed_time,maximum_elapsed_time FROM APEX_WORKSPACE_LOG_SUMMARY"); 10 | break; 11 | case "sessions": 12 | runReport("select * from APEX_WORKSPACE_SESSIONS"); 13 | break; 14 | case "devs": 15 | runReport("select * from APEX_WORKSPACE_DEVELOPERS"); 16 | break; 17 | case "users": 18 | runReport("select * from APEX_WORKSPACE_APEX_USERS"); 19 | break; 20 | default: 21 | sqlcl.setStmt("select WORKSPACE,APPLICATION_ID,APPLICATION_NAME,ALIAS from apex_applications"); 22 | sqlcl.run(); 23 | break; 24 | } 25 | } catch(e){ 26 | ctx.write(e +"\n") 27 | } 28 | } else { 29 | ctx.write("\n Usages: myapex....\n"); 30 | } 31 | } 32 | 33 | function runReport(sql){ 34 | sqlcl.setStmt(sql) 35 | sqlcl.run(); 36 | } 37 | function setupOWA(){ 38 | util.execute("declare nm owa.vc_arr; vl owa.vc_arr; begin nm(1) := 'WEB_AUTHENT_PREFIX'; vl(1) := 'WEB$'; owa.init_cgi_env( 1, nm, vl ); sys.htp.htbuf_len := 84; end;"); 39 | } 40 | function exportApp(conn,appId){ 41 | // setup the OWA env 42 | setupOWA(); 43 | var binds = {}; 44 | binds.APPLICATION_ID = appId; 45 | 46 | // lookup the workspace ID 47 | binds.WORKSPACE_ID = util.executeReturnOneCol("select workspace_id from apex_applications where application_id = :APPLICATION_ID", binds); 48 | // do it 49 | util.execute("begin apex_util.export_application(p_application_id=>:APPLICATION_ID,p_workspace_id=>:WORKSPACE_ID); end; ", binds); 50 | // get the OWA buffer 51 | var page = getPage(conn); 52 | // print it 53 | ctx.write(page); 54 | 55 | } 56 | // reusable function to get anything in the OWA bugger 57 | function getPage(conn){ 58 | try { 59 | var Types = Java.type("java.sql.Types") 60 | var BufferedReader = Java.type("java.io.BufferedReader") 61 | var InputStreamReader = Java.type("java.io.InputStreamReader") 62 | 63 | var GET_PAGE = "declare " + //$NON-NLS-1$ 64 | " l_buf varchar2(32767); " + //$NON-NLS-1$ 65 | " l_clob CLOB; " + //$NON-NLS-1$ 66 | " l_lines htp.htbuf_arr; " + //$NON-NLS-1$ 67 | " l_num number := 999999; " + //$NON-NLS-1$ 68 | " begin " + //$NON-NLS-1$ 69 | " dbms_lob.createtemporary(l_clob, TRUE); " + //$NON-NLS-1$ 70 | " OWA.GET_PAGE(l_lines, l_num); " + //$NON-NLS-1$ 71 | " for i in 1..l_num loop " + //$NON-NLS-1$ 72 | " dbms_lob.append(l_clob,l_lines(i)); " + //$NON-NLS-1$ 73 | " end loop; " + //$NON-NLS-1$ 74 | " ? := l_clob;" + //$NON-NLS-1$ 75 | " end;"; //$NON-NLS-1$ 76 | 77 | var cs = conn.prepareCall(GET_PAGE); 78 | cs.registerOutParameter(1, Types.CLOB); 79 | cs.execute(); 80 | var clob = cs.getClob(1); 81 | 82 | var r = new BufferedReader(new InputStreamReader(clob.getAsciiStream(), "UTF-8")) 83 | var str = null; 84 | var content = ""; 85 | while ((str = r.readLine()) != null) { content = content + str + "\n"; } 86 | cs.close(); 87 | return content; 88 | }catch(e){ 89 | ctx.write(e +"\n") 90 | } 91 | 92 | } 93 | 94 | // SQLCL's Command Registry 95 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 96 | 97 | // CommandListener for creating any new command 98 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 99 | 100 | // Broke the .js out from the Java.extend to be easier to read 101 | var cmd = {}; 102 | 103 | // Called to attempt to handle any command 104 | cmd.handle = function (conn,ctx,cmd) { 105 | var subCmd = cmd.getSql().trim().split(" ") 106 | // my command name is "myapex *" 107 | if ( subCmd[0].equalsIgnoreCase("apx")){ 108 | processApex(ctx,conn,subCmd) 109 | return true; 110 | } 111 | return false; 112 | } 113 | 114 | // fired before ANY command 115 | cmd.begin = function (conn,ctx,cmd) { 116 | } 117 | 118 | // fired after ANY Command 119 | cmd.end = function (conn,ctx,cmd) { 120 | } 121 | 122 | // Actual Extend of the Java CommandListener 123 | var MyApexCmd = Java.extend(CommandListener, { 124 | handleEvent: cmd.handle , 125 | beginEvent: cmd.begin , 126 | endEvent: cmd.end 127 | }); 128 | 129 | // Registering the new Command 130 | CommandRegistry.addForAllStmtsListener(MyApexCmd.class); 131 | 132 | 133 | -------------------------------------------------------------------------------- /sqlcl/examples/args.js: -------------------------------------------------------------------------------- 1 | /* loop over all args passed in and print them */ 2 | for(var arg in args) { 3 | ctx.write(arg + ":" + args[arg]); 4 | ctx.write("\n"); 5 | } 6 | -------------------------------------------------------------------------------- /sqlcl/examples/audio.js: -------------------------------------------------------------------------------- 1 | // SQLCL's Command Registry 2 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 3 | 4 | // CommandListener for creating any new command 5 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 6 | var AudioSystem = Java.type("javax.sound.sampled.AudioSystem"); 7 | var File = Java.type("java.io.File"); 8 | 9 | function play(sound){ 10 | try { 11 | var path = new File(sound); 12 | var audioInputStream = AudioSystem.getAudioInputStream(path); 13 | var clip = AudioSystem.getClip(); 14 | clip.open(audioInputStream); 15 | clip.start(); 16 | } catch( ex) { 17 | ctx.write("Error with playing sound.\n"); 18 | ex.printStackTrace(); 19 | } 20 | } 21 | 22 | 23 | // Broke the .js out from the Java.extend to be easier to read 24 | var cmd = {}; 25 | 26 | // Called to attempt to handle any command 27 | cmd.handle = function (conn,ctx,cmd) { 28 | return false; 29 | } 30 | 31 | // fired before ANY command 32 | cmd.begin = function (conn,ctx,cmd) { 33 | 34 | } 35 | 36 | // fired after ANY Command 37 | cmd.end = function (conn,ctx,cmd) { 38 | if ( ctx.getProperty("sqldev.last.err.message") ) { 39 | 40 | // 41 | // GET FILES and customize 42 | // 43 | 44 | 45 | play("chew_roar.wav"); 46 | } else { 47 | 48 | // 49 | // GET FILES and customize 50 | // 51 | play("R2.wav"); 52 | } 53 | } 54 | 55 | // Actual Extend of the Java CommandListener 56 | 57 | var SoundCommand = Java.extend(CommandListener, { 58 | handleEvent: cmd.handle , 59 | beginEvent: cmd.begin , 60 | endEvent: cmd.end 61 | }); 62 | 63 | // Registering the new Command 64 | CommandRegistry.addForAllStmtsListener(SoundCommand.class); 65 | 66 | 67 | -------------------------------------------------------------------------------- /sqlcl/examples/autocorrect.js: -------------------------------------------------------------------------------- 1 | 2 | var fatFinger = [ { bad:"form", good:"from"}, 3 | { bad:"hwere", good:"where"}, 4 | { bad:"“", good:"\"" , all:true}, 5 | { bad:"”", good:"\"" , all:true}, 6 | { bad:"dula", good:"dual"} 7 | ]; 8 | 9 | 10 | 11 | 12 | // SQLCL's Command Registry 13 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 14 | 15 | // CommandListener for creating any new command 16 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 17 | 18 | 19 | // Broke the .js out from the Java.extend to be easier to read 20 | var cmd = {}; 21 | 22 | // Called to attempt to handle any command 23 | cmd.handle = function (conn,ctx,cmd) { 24 | return false; 25 | } 26 | 27 | // fired before ANY command 28 | cmd.begin = function (conn,ctx,cmd) { 29 | for(var i = 0; i < fatFinger.length; i++) { 30 | var w = fatFinger[i]; 31 | if ( cmd.getSql().trim().indexOf(" "+ w.bad +" ") >0 ) { 32 | ctx.write("\n***Mispelled "+ w.bad +" again. AUTOCORRECTING ***\n"); 33 | cmd.setSql(cmd.getSql().replace(" "+ w.bad +" ", " "+ w.good +" /* AUTO CORRECTED */ ")); 34 | } else if ( w.all && cmd.getSql().trim().indexOf( w.bad ) >0 ) { 35 | ctx.write("\n***Mispelled "+ w.bad +" again. AUTOCORRECTING ***\n"); 36 | cmd.setSql(cmd.getSql().replace( w.bad , w.good )); 37 | } 38 | } 39 | 40 | 41 | } 42 | 43 | // fired after ANY Command 44 | cmd.end = function (conn,ctx,cmd) { 45 | } 46 | 47 | // Actual Extend of the Java CommandListener 48 | 49 | var AutoCorrectCommand = Java.extend(CommandListener, { 50 | handleEvent: cmd.handle , 51 | beginEvent: cmd.begin , 52 | endEvent: cmd.end 53 | }); 54 | 55 | // Registering the new Command 56 | CommandRegistry.addForAllStmtsListener(AutoCorrectCommand.class); 57 | 58 | 59 | -------------------------------------------------------------------------------- /sqlcl/examples/bg.js: -------------------------------------------------------------------------------- 1 | // declare the 2 java files needed 2 | var DriverManager = Java.type("java.sql.DriverManager"); 3 | var ScriptExecutor = Java.type("oracle.dbtools.raptor.newscriptrunner.ScriptExecutor"); 4 | 5 | var BGsql=""; 6 | for(var i=1;i") 42 | if ( emoji[key] && emoji[key].char ) { 43 | //ctx.write( emoji[key].char ) 44 | var binds = {}; 45 | binds.keyword = key; 46 | binds.emoji = emoji[key].char; 47 | var ret = util.execute("insert into emoji(keyword,emoji) values(:keyword , :emoji)",binds); 48 | } 49 | } 50 | ctx.write( "\n\n" ) 51 | / 52 | select * from emoji order by keyword; 53 | / 54 | -------------------------------------------------------------------------------- /sqlcl/examples/exec.js: -------------------------------------------------------------------------------- 1 | load('https://raw.githubusercontent.com/oracle/Oracle_DB_Tools/master/sqlcl/lib/helpers.js'); 2 | 3 | /* execute the host command and grab the returned object */ 4 | var ret = helpers.exec('ls -l'); 5 | 6 | ctx.write("Return Code:\n"); 7 | ctx.write(ret.rc + "\n"); 8 | 9 | ctx.write("STDOUT:\n"); 10 | ctx.write(ret.stdout + "\n"); 11 | 12 | ctx.write("STDERR:\n"); 13 | ctx.write(ret.stderr + "\n"); 14 | -------------------------------------------------------------------------------- /sqlcl/examples/jython_example.sh: -------------------------------------------------------------------------------- 1 | # all files in sqlcl/lib/* 2 | 3 | CP=SQLinForm.jar:commons-codec.jar:commons-logging.jar:httpclient.jar:httpcore.jar:httpmime.jar:jackson-annotations.jar:jackson-core.jar:jackson-databind.jar:javax.json.jar:jline.jar:jsch.jar:k.sh:ojdbc7.jar:oracle.dbtools-common.jar:oracle.dbtools.http.jar:oracle.dbtools.jdbcrest.jar:oracle.sqldeveloper.sqlcl.jar:oraclepki.jar:orai18n-mapping.jar:orai18n-utility.jar:orai18n.jar:orajsoda.jar:osdt_cert.jar:osdt_core.jar:xdb6.jar:xmlparserv2.jar 4 | 5 | #jython till EOF 6 | jython -Dpython.path=$CP < to a JSON object. */ 36 | helpers.resultsToJSON=function(ret){ 37 | var data = [] ; 38 | for ( r in ret ) { 39 | /* loop all the columns in the row */ 40 | var set = ret[r].keySet().iterator();; 41 | var row = {}; 42 | while( set.hasNext() ) { 43 | var key = set.next(); 44 | row[key] = ret[r][key]; 45 | } 46 | data[data.length] = row; 47 | } 48 | return data; 49 | 50 | } 51 | 52 | /* 53 | * Runs the passed in command and returns an Object with 54 | * .rc - the return code 55 | * .stdout - STDOUT 56 | * .stderr - STDERR 57 | * 58 | */ 59 | helpers.exec=function(cmd){ 60 | var RunTime = Java.type("java.lang.Runtime"); 61 | var Scanner = Java.type("java.util.Scanner"); 62 | var p = RunTime.getRuntime().exec(cmd); 63 | 64 | var ret={}; 65 | s = new Scanner(p.getInputStream()).useDelimiter("\\A"); 66 | ret.stdout = s.hasNext() ? s.next().trim() : ""; 67 | s = new Scanner(p.getErrorStream()).useDelimiter("\\A"); 68 | ret.stderr = s.hasNext() ? s.next().trim() : ""; 69 | 70 | p.waitFor(); 71 | ret.rc = p.exitValue(); 72 | p.destroy(); 73 | return ret; 74 | } 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /sqlcl/examples/longops.js: -------------------------------------------------------------------------------- 1 | // declare the java classes needed 2 | var DriverManager = Java.type("java.sql.DriverManager"); 3 | var DBUtil = Java.type("oracle.dbtools.db.DBUtil"); 4 | var Thread = Java.type("java.lang.Thread"); 5 | var System = Java.type("java.lang.System"); 6 | 7 | // Create a new connection to use for monitoring 8 | // Grab the connect URL from the base connection in sqlcl 9 | if ( typeof conn !== 'undefined' ) { 10 | 11 | var LongOpsBinds = {}; 12 | 13 | // long ops sql 14 | var sql = " SELECT sid, to_char(start_time,'hh24:mi:ss') stime, " + 15 | " message,( sofar/totalwork)* 100 percent " + 16 | " FROM v$session_longops " + 17 | " WHERE sofar/totalwork < 1" + 18 | " and sid = :SID"; 19 | 20 | if ( !conn ) { 21 | System.out.println(" Not Monitoring , not connected "); 22 | }else { 23 | // grab SQLCL session's SID 24 | var SID = util.executeReturnOneCol("select sys_context('USERENV','SID') from dual") 25 | LongOpsBinds.SID = SID; 26 | 27 | // start it up 28 | runme(); 29 | 30 | } 31 | } else { 32 | System.out.println("Not Connected, longops could not run "); 33 | } 34 | 35 | function main(arg){ 36 | function inner(){ 37 | System.out.println("\nStarting Monitoring sid= " + LongOpsBinds.SID ) 38 | //connect 39 | try { 40 | var conn2 = ctx.cloneCLIConnection(); 41 | var util2 = DBUtil.getInstance(conn2); 42 | var last = 0; 43 | // run always ! 44 | while(true) { 45 | ret = util2.executeReturnList(sql,LongOpsBinds); 46 | // only print if the percent changed 47 | if ( ret.length > 0 && last != ret[0].PERCENT ){ 48 | last = ret[0].PERCENT; 49 | System.out.println( ret[0].STIME + "> " + ret[0].PERCENT + ' Completed \t' + ret[0].MESSAGE); 50 | } 51 | // sleepy time 52 | Thread.sleep(1000); 53 | } 54 | System.out.println("\nDone Monitoring") 55 | conn2.close(); 56 | } catch (e) { 57 | System.out.println("\nLong Ops Monitoring Failed:" + e.getLocalizedMessage()); 58 | } 59 | } 60 | return inner; 61 | }; 62 | 63 | 64 | function runme(){ 65 | // import and alias Java Thread and Runnable classes 66 | var Thread = Java.type("java.lang.Thread"); 67 | var Runnable = Java.type("java.lang.Runnable"); 68 | 69 | // declare our thread 70 | this.thread = new Thread(new Runnable(){ 71 | run: main() 72 | }); 73 | 74 | // start our thread 75 | this.thread.start(); 76 | return; 77 | } 78 | -------------------------------------------------------------------------------- /sqlcl/examples/numbers.sql: -------------------------------------------------------------------------------- 1 | prompt set sqlformat ansiconsole 2 | set sqlformat ansiconsole 3 | select 1234567890 from dual; 4 | 5 | prompt set sqlformat ansiconsole default 6 | set sqlformat ansiconsole default 7 | select 1234567890 from dual; 8 | 9 | prompt set sqlformat ansiconsole ##.##E00 10 | set sqlformat ansiconsole ##.##E00 11 | select 1234567890 from dual; 12 | 13 | prompt set sqlformat ansiconsole #,##0.00;(#,##0.00) 14 | set sqlformat ansiconsole #,##0.00;(#,##0.00) 15 | select 1234567890,-1234567890 from dual; 16 | 17 | prompt set sqlformat ansiconsole #,##0.00;@|red -#,##0.00|@ 18 | set sqlformat ansiconsole #,##0.00;@|red -#,##0.00|@ 19 | select 1234567890,-1234567890 from dual; 20 | 21 | prompt set sqlformat ansiconsole #,##0.00;@|underline -#,##0.00|@ 22 | set sqlformat ansiconsole #,##0.00;@|underline -#,##0.00|@ 23 | select 1234567890,-1234567890 from dual; 24 | -------------------------------------------------------------------------------- /sqlcl/examples/printtab.js: -------------------------------------------------------------------------------- 1 | /* rebuild the sql that was passed in as args*/ 2 | var sql=""; 3 | for(var i=1;iROW \n'); 15 | /* loop the columns in the row */ 16 | for( var ii=0;ii0 ) { 21 | ctx.write(args[i] + " is Reserved\n"); 22 | } else { 23 | ctx.write(args[i] + " is not Reserved\n"); 24 | } 25 | } 26 | } 27 | return true; 28 | } 29 | return false; 30 | } 31 | 32 | // fired before ANY command 33 | cmd.begin = function (conn,ctx,cmd) { 34 | } 35 | 36 | // fired after ANY Command 37 | cmd.end = function (conn,ctx,cmd) { 38 | } 39 | 40 | // Actual Extend of the Java CommandListener 41 | 42 | var ReservedCommand = Java.extend(CommandListener, { 43 | handleEvent: cmd.handle , 44 | beginEvent: cmd.begin , 45 | endEvent: cmd.end 46 | }); 47 | 48 | // Registering the new Command 49 | CommandRegistry.addForAllStmtsListener(ReservedCommand.class); 50 | 51 | 52 | -------------------------------------------------------------------------------- /sqlcl/examples/rspool.js: -------------------------------------------------------------------------------- 1 | // SQLCL's Command Registry 2 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 3 | 4 | // CommandListener for creating any new command 5 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 6 | 7 | var MultiLineHistory = Java.type("oracle.dbtools.raptor.console.MultiLineHistory") 8 | 9 | // Broke the .js out from the Java.extend to be easier to read 10 | var cmd = {}; 11 | 12 | // Called to attempt to handle any command 13 | cmd.handle = function (conn,ctx,cmd) { 14 | if ( cmd.getSql().trim().startsWith("rspool") ) { 15 | // split up the args for better names 16 | var sql = cmd.getSql().trim(); 17 | var args = sql.split(/\s+/); 18 | var iterations = args[1] ; 19 | var sleep = args[2] ; 20 | var fname = args[3] ; 21 | if ( args.length < 4 ){ 22 | ctx.write("Usage : rspool "); 23 | return true; 24 | } 25 | // find the last select from history 26 | var repeatSQL = getLastSelect(); 27 | 28 | if ( repeatSQL ){ 29 | var i=0; 30 | // do stuff 31 | while( i <= iterations ){ 32 | ctx.write("Loop:" + i + " of " + iterations + " with a sleep of " + sleep + "s\n"); 33 | run("spool " + fname+ "." + i + ".log;" ); 34 | run(repeatSQL + ";\n"); 35 | run(" spool off"); 36 | if (i != iterations) { 37 | try { 38 | Thread.sleep( Math.round(sleep * 1000)); 39 | } catch ( e) { 40 | break; 41 | } 42 | } 43 | i++; 44 | } 45 | } 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | // fired before ANY command 52 | cmd.begin = function (conn,ctx,cmd) { 53 | } 54 | 55 | // fired after ANY Command 56 | cmd.end = function (conn,ctx,cmd) { 57 | } 58 | 59 | // Actual Extend of the Java CommandListener 60 | 61 | var RSpoolCommand = Java.extend(CommandListener, { 62 | handleEvent: cmd.handle , 63 | beginEvent: cmd.begin , 64 | endEvent: cmd.end 65 | }); 66 | 67 | // Registering the new Command 68 | CommandRegistry.addForAllStmtsListener(RSpoolCommand.class); 69 | 70 | // run stuff 71 | function run(sql){ 72 | sqlcl.setStmt(sql); 73 | sqlcl.run(); 74 | } 75 | // find last select or with statement 76 | function getLastSelect(){ 77 | var MultiLineHistory = Java.type("oracle.dbtools.raptor.console.MultiLineHistory"); 78 | var nextCmd = null; 79 | var check=MultiLineHistory.getInstance().size(); 80 | while(check>-1 && nextCmd==null){ 81 | var next = MultiLineHistory.getInstance().get(check); 82 | if ( next.toLowerCase().startsWith("select ") || next.toLowerCase().startsWith("with ") ){ 83 | nextCmd = next; 84 | } 85 | check--; 86 | } 87 | return nextCmd; 88 | } -------------------------------------------------------------------------------- /sqlcl/examples/snark.js: -------------------------------------------------------------------------------- 1 | // SQLCL's Command Registry 2 | var CommandRegistry = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandRegistry"); 3 | 4 | // CommandListener for creating any new command 5 | var CommandListener = Java.type("oracle.dbtools.raptor.newscriptrunner.CommandListener") 6 | 7 | // Broke the .js out from the Java.extend to be easier to read 8 | var cmd = {}; 9 | 10 | // Called to attempt to handle any command 11 | cmd.handle = function (conn,ctx,cmd) { 12 | return false; 13 | } 14 | 15 | // fired before ANY command 16 | cmd.begin = function (conn,ctx,cmd) { 17 | if ( cmd.getSql().trim().equalsIgnoreCase("select 1 from dual") ) { 18 | ctx.write("\nReally? Come on man, Try something harder next time.\n"); 19 | } 20 | } 21 | 22 | // fired after ANY Command 23 | cmd.end = function (conn,ctx,cmd) { 24 | if ( cmd.getSql().trim().equalsIgnoreCase("select 1 from dual") ) { 25 | ctx.write("\nWhat'd you really expect???.\n"); 26 | } 27 | } 28 | 29 | // Actual Extend of the Java CommandListener 30 | 31 | var SnarkCommand = Java.extend(CommandListener, { 32 | handleEvent: cmd.handle , 33 | beginEvent: cmd.begin , 34 | endEvent: cmd.end 35 | }); 36 | 37 | // Registering the new Command 38 | CommandRegistry.addForAllStmtsListener(SnarkCommand.class); 39 | 40 | 41 | -------------------------------------------------------------------------------- /sqlcl/examples/sql.ecma6.js: -------------------------------------------------------------------------------- 1 | /* Look up a single value to use in a bind later */ 2 | var user = util.executeReturnOneCol('select user from dual'); 3 | 4 | var binds = {}; 5 | binds.name = 'EMPLOYEES'; 6 | binds.who = user; 7 | 8 | ctx.write('Using Binds:'+ binds + '\n'); 9 | 10 | ctx.write(` 11 | *************************************************************** 12 | ***** SIMPLE LOOP OF LIST OF LIST *********** 13 | ***************************************************************\n`); 14 | 15 | var ret = util.executeReturnListofList(`select object_name,object_type 16 | from all_objects 17 | where object_name = :name 18 | and owner = :who `,binds); 19 | 20 | for (var i = 0; i < ret.length; i++) { 21 | ctx.write( ` ${ret[i][1]} \t ${ret[i][0]} \n`); 22 | } 23 | 24 | ctx.write('\n\n'); 25 | 26 | ctx.write(` 27 | *************************************************************** 28 | ***** SIMPLE LOOP OF LIST OF NAMES WITH BINDS ********** 29 | ***************************************************************\n`); 30 | 31 | ret = util.executeReturnList(`select object_name,object_type 32 | from all_objects 33 | where object_name = :name 34 | and owner = :who `,binds); 35 | 36 | for (i = 0; i < ret.length; i++) { 37 | ctx.write( ` ${ret[i].OBJECT_TYPE} \t ${ret[i].OBJECT_NAME} \n`); 38 | } 39 | -------------------------------------------------------------------------------- /sqlcl/examples/sql.js: -------------------------------------------------------------------------------- 1 | /* Look up a single value to use in a bind later */ 2 | var user = util.executeReturnOneCol('select user from dual'); 3 | 4 | /* simple string or number binds can be a js object */ 5 | var binds = {}; 6 | binds.name = 'EMP'; 7 | binds.who = user; 8 | 9 | ctx.write('Using Binds:'+ binds + '\n'); 10 | 11 | ctx.write('***************************************************************\n'); 12 | ctx.write('***** SIMPLE LOOP OF LIST OF LIST ***********\n'); 13 | ctx.write('***************************************************************\n'); 14 | 15 | 16 | var ret = util.executeReturnListofList('select object_name,object_type from all_objects where object_name = :name and owner = :who ',binds); 17 | 18 | for (var i = 0; i < ret.length; i++) { 19 | ctx.write( ret[i][1] + "\t" + ret[i][0] + "\n"); 20 | } 21 | 22 | ctx.write('\n\n'); 23 | 24 | ctx.write('***************************************************************\n'); 25 | ctx.write('***** SIMPLE LOOP OF LIST OF NAMES WITH BINDS **********\n'); 26 | ctx.write('***************************************************************\n'); 27 | 28 | 29 | ret = util.executeReturnList('select object_name,object_type from all_objects where object_name = :name and owner = :who ',binds); 30 | 31 | for (i = 0; i < ret.length; i++) { 32 | ctx.write( ret[i].OBJECT_TYPE + "\t" + ret[i].OBJECT_NAME+ "\n"); 33 | } 34 | -------------------------------------------------------------------------------- /sqlcl/examples/sqlprompt.js: -------------------------------------------------------------------------------- 1 | /* execute a sql and get the first column of the first row as a return*/ 2 | var dbUser = util.executeReturnOneCol('select user from dual'); 3 | 4 | 5 | /* based on the connect user change my SQL prompt*/ 6 | if ( dbUser == 'KLRICE' ) { 7 | sqlcl.setStmt('set sqlprompt "@|red _USER|@@@|green _CONNECT_IDENTIFIER|@@|blue 🍻🍺 >|@"'); 8 | } else { 9 | sqlcl.setStmt('set sqlprompt "@|blue _USER|@@@|green _CONNECT_IDENTIFIER|@@|blue 🍼 >|@"'); 10 | } 11 | 12 | sqlcl.run(); 13 | -------------------------------------------------------------------------------- /sqlcl/examples/stats.js: -------------------------------------------------------------------------------- 1 | // declare the 2 java files needed 2 | var DriverManager = Java.type("java.sql.DriverManager"); 3 | var DBUtil = Java.type("oracle.dbtools.db.DBUtil"); 4 | 5 | 6 | // Create a new connection to use for monitoring 7 | // Grab the connect URL from the base connection in sqlcl 8 | var jdbc = conn.getMetaData().getURL(); 9 | var user = 'klrice'; 10 | var pass = 'klrice'; 11 | 12 | //connect 13 | var conn2 = DriverManager.getConnection(jdbc,user,pass); 14 | var util2 = DBUtil.getInstance(conn2); 15 | 16 | // probably a better way to rpad a string 17 | function pad(s,n){ 18 | s = s.toString() + " "; 19 | return ( s.substring(0,n)); 20 | } 21 | 22 | // 23 | // Simple function to grab the session stats and put them into JSON 24 | // 25 | function stats2json(sid){ 26 | var binds = {}; 27 | binds.SID = sid; 28 | 29 | var list = util2.executeReturnList("select name,value from v$statname sn,v$sesstat s where sn.statistic# = s.STATISTIC# and s.SID= :SID",binds); 30 | var ret={}; 31 | for (var i = 0; i < list.length; i++) { 32 | ret[list[i].NAME] = parseInt(list[i].VALUE); 33 | } 34 | return ret; 35 | } 36 | 37 | // 38 | // Simple function to grab the session details and put them into JSON 39 | // 40 | function getSession(util){ 41 | /* Current active SQL Connection */ 42 | var results = util.executeReturnList("select sys_context('USERENV','session_user') u,sys_context('USERENV','SESSIONID') sessionID,sys_context('USERENV','SID') sid from dual",null); 43 | 44 | var ret = {}; 45 | ret.user = results[0].U; 46 | ret.sid = results[0].SID; 47 | ret.sessionid = results[0].SESSIONID; 48 | 49 | ctx.write("\tUser:" + ret.user + "\n"); 50 | ctx.write("\tSID:" + ret.sid + "\n"); 51 | ctx.write("\tSession:" + ret.sessionid + "\n"); 52 | 53 | return ret; 54 | } 55 | 56 | // rebuild the arguments which are the commands to run 57 | var sql=""; 58 | for(var i=1;i h, \n " + 42 | " document => sxml_from); \n " + 43 | 44 | " dbms_metadata_diff.add_document ( \n " + 45 | " handle => h, \n " + 46 | " document => sxml_to); \n " + 47 | 48 | " tc1 := sys.dbms_metadata_diff.fetch_clob(h); \n " + 49 | " dbms_metadata_diff.close(h); \n " + 50 | 51 | 52 | " -- Open a context and add ALTERXML transform to generate ALTER_XML \n " + 53 | " -- required for the above diff document. \n " + 54 | " h := dbms_metadata.openw('TABLE'); \n " + 55 | " th1 := dbms_metadata.add_transform(h, 'ALTERXML'); \n " + 56 | 57 | " -- create a temporary lob for alter XML statements and do the convert \n " + 58 | " th2 := dbms_metadata.add_transform(h, 'ALTERDDL'); \n " + 59 | 60 | " -- create a temporary lob for alter statements and do the convert \n " + 61 | " -- LOB is already package scope and may have old contents from a \n " + 62 | " -- prev. call \n " + 63 | " DBMS_LOB.CREATETEMPORARY(r, TRUE ); \n " + 64 | " dbms_metadata.convert(h, tc1, r); \n " + 65 | " dbms_metadata.close(h); \n " + 66 | " ? := r; \n " + 67 | " end; \n "; 68 | 69 | 70 | // call the plsql 71 | var call = conn.prepareCall(sql); 72 | call.setString(1,args[1]) 73 | call.setString(2,args[2]) 74 | call.registerOutParameter(3,Types.CLOB); 75 | call.execute(); 76 | var clob = call.getClob(3); 77 | 78 | // get the results 79 | var results = clob.getSubString(1, clob.length()); 80 | 81 | ctx.write(results); 82 | 83 | return true; 84 | } 85 | return false; 86 | } 87 | 88 | // fired before ANY command 89 | cmd.begin = function (conn,ctx,cmd) { 90 | 91 | } 92 | 93 | // fired after ANY Command 94 | cmd.end = function (conn,ctx,cmd) { 95 | } 96 | 97 | // Actual Extend of the Java CommandListener 98 | 99 | var SyncCommand = Java.extend(CommandListener, { 100 | handleEvent: cmd.handle , 101 | beginEvent: cmd.begin , 102 | endEvent: cmd.end 103 | }); 104 | 105 | // Registering the new Command 106 | CommandRegistry.addForAllStmtsListener(SyncCommand.class); 107 | 108 | 109 | -------------------------------------------------------------------------------- /sqlcl/images/csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/images/csv.png -------------------------------------------------------------------------------- /sqlcl/images/inline1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/images/inline1.png -------------------------------------------------------------------------------- /sqlcl/images/inline2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/images/inline2.png -------------------------------------------------------------------------------- /sqlcl/images/sql-command-line-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/images/sql-command-line-200.png -------------------------------------------------------------------------------- /sqlcl/images/traffic_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/images/traffic_light.png -------------------------------------------------------------------------------- /sqlcl/java/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /sqlcl/java/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /sql/ 3 | -------------------------------------------------------------------------------- /sqlcl/java/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | sqlcl-java 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /sqlcl/java/README.md: -------------------------------------------------------------------------------- 1 | # sqlcl-java 2 | 3 | This repository is a few examples of how to use [Oracle SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) as a Java library. 4 | 5 | # Env / Eclipse Setup 6 | 7 | 1. Download SQLcl 8 | 2. Unzip SQLcl 9 | 3. Add sql/lib/* files to the classpath 10 | 11 | ![](sqlcl-eclipse-path.png) 12 | 13 | # 14 | 15 | # Examples 16 | 17 | 18 | ## Run Entire script 19 | This example uses the @myfile 'normal' sqlcl / sqlplus syntax to run and entire script. 20 | 21 | [RunMyScript](src/RunMyScript.java) 22 | 23 | 24 | ## ParseScript and Execute 25 | This is an example of parsing a file with the SQLcl script parser. Then iterating over the array of commands to execute and detect errors to be handled. 26 | 27 | [ParseScriptRunOneAtATime.java](src/ParseScriptRunOneAtATime.java) 28 | 29 | 30 | > Only 0 rows currently supported in a script resultsno rows selected 31 | > 32 | > Table KLRICE_TEST created. 33 | > 34 | > 35 | > 1 row inserted. 36 | > 37 | > 38 | > 1 row inserted. 39 | > 40 | > 41 | > 1 row inserted. 42 | > 43 | > Only 0 rows currently supported in a script resultsno rows selected 44 | > 45 | > Rollback complete. 46 | > 47 | > no rows selected 48 | > 49 | > Table KLRICE_TEST dropped. 50 | -------------------------------------------------------------------------------- /sqlcl/java/myfile.sql: -------------------------------------------------------------------------------- 1 | select * from user_objects; 2 | 3 | create table klrice_test( 4 | id number, 5 | name varchar2(200) 6 | ); 7 | insert into klrice_test values(1,'hi'); 8 | insert into klrice_test values(2,'hi again'); 9 | insert into klrice_test values(3,'cya'); 10 | select * from klrice_test; 11 | rollback; 12 | 13 | select * from klrice_test; 14 | drop table klrice_test; 15 | -------------------------------------------------------------------------------- /sqlcl/java/sqlcl-eclipse-path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/java/sqlcl-eclipse-path.png -------------------------------------------------------------------------------- /sqlcl/java/src/ParseScriptRunOneAtATime.java: -------------------------------------------------------------------------------- 1 | import java.io.BufferedOutputStream; 2 | import java.io.ByteArrayOutputStream; 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.sql.Connection; 7 | import java.sql.DriverManager; 8 | import java.sql.SQLException; 9 | 10 | import oracle.dbtools.raptor.newscriptrunner.ISQLCommand; 11 | import oracle.dbtools.raptor.newscriptrunner.ScriptParser; 12 | import oracle.dbtools.raptor.newscriptrunner.ScriptRunner; 13 | import oracle.dbtools.raptor.newscriptrunner.ScriptRunnerContext; 14 | 15 | public class ParseScriptRunOneAtATime { 16 | public static void main(String[] args) throws SQLException, IOException { 17 | Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/XE", "klrice", "klrice"); 18 | conn.setAutoCommit(false); 19 | ///Users/klrice/workspace_commons/sqlcl-java/ 20 | FileInputStream fin = new FileInputStream(new File("myfile.sql")); 21 | ScriptParser parser = new ScriptParser(fin); 22 | 23 | ISQLCommand cmd; 24 | // #setup the context 25 | ScriptRunnerContext ctx = new ScriptRunnerContext(); 26 | ctx.setBaseConnection(conn); 27 | 28 | 29 | // Capture the results without this it goes to STDOUT 30 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); 31 | BufferedOutputStream buf = new BufferedOutputStream(bout); 32 | 33 | 34 | ScriptRunner sr = new ScriptRunner(conn, buf, ctx); 35 | while ( ( cmd = parser.next() ) != null ) { 36 | // do something fancy based on a cmd 37 | sr.run(cmd); 38 | // check success/failure of the command 39 | 40 | String errMsg = (String) ctx.getProperty(ScriptRunnerContext.ERR_MESSAGE); 41 | if ( errMsg != null ){ 42 | // react to a failure 43 | System.out.println("**FAILURE**" + errMsg); 44 | } 45 | } 46 | 47 | String results = bout.toString("UTF8"); 48 | results = results.replaceAll(" force_print\n", ""); 49 | System.out.println(results); 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /sqlcl/java/src/RunMyScript.java: -------------------------------------------------------------------------------- 1 | import java.io.BufferedOutputStream; 2 | import java.io.ByteArrayOutputStream; 3 | import java.io.UnsupportedEncodingException; 4 | import java.sql.Connection; 5 | import java.sql.DriverManager; 6 | import java.sql.SQLException; 7 | 8 | import oracle.dbtools.raptor.newscriptrunner.ScriptExecutor; 9 | import oracle.dbtools.raptor.newscriptrunner.ScriptRunnerContext; 10 | import oracle.dbtools.db.ResultSetFormatter; 11 | 12 | 13 | public class RunMyScript { 14 | 15 | public static void main(String[] args) throws SQLException, UnsupportedEncodingException { 16 | Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/XE", "klrice", "klrice"); 17 | conn.setAutoCommit(false); 18 | 19 | // #create sqlcl 20 | ScriptExecutor sqlcl = new ScriptExecutor(conn); 21 | 22 | // #setup the context 23 | ScriptRunnerContext ctx = new ScriptRunnerContext(); 24 | 25 | // set the output max rows 26 | ResultSetFormatter.setMaxRows(10000); 27 | // #set the context 28 | sqlcl.setScriptRunnerContext(ctx); 29 | ctx.setBaseConnection(conn); 30 | 31 | // Capture the results without this it goes to STDOUT 32 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); 33 | BufferedOutputStream buf = new BufferedOutputStream(bout); 34 | sqlcl.setOut(buf); 35 | 36 | 37 | // # run a whole file 38 | // adjust the path as it needs to be absolute 39 | sqlcl.setStmt("@/Users/klrice/workspace_commons/sqlcl-java/myfile.sql"); 40 | sqlcl.run(); 41 | 42 | 43 | String results = bout.toString("UTF8"); 44 | results = results.replaceAll(" force_print\n", ""); 45 | System.out.println(results); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /sqlcl/sql-command-line-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/oracle-db-tools/f7f7b9ad0b5c57530a779d4b430da0e1ab193b67/sqlcl/sql-command-line-200.png --------------------------------------------------------------------------------