Giter Club home page Giter Club logo

sqlcl's Introduction

Content

SQLcl - Scripting

Learn how to create custom scripts for SQLcl.

SQLcl allows you to execute scripts. The main reason is to extend its functionality and automate your tasks as developer. This way you can interact with both the Database and local files (such as Database Objects and SQL scripts)

The JavaScript Engine for SQLcl is Oracle Nashorn.

You can use scripts in two ways:

  1. Via the script command
  2. Inside an alias

This project shows you:

  • a way to test your SQLcl scripts in Netbeans IDE
  • Lots of examples for script and alias commands

Download SQLcl at:

Configure SQLcl

Add to PATH

In order to use SQLcl from the command-line in any given directory, you need to add the sqlcl/bin folder to the PATH variable.

login.sql

The login.sql and glogin.sql scripts are executed when you start SQLcl. This is the place where you load your SQLcl scripts at startup.

SET sqlprompt "_user'@'_connect_identifier > "
SET sqlformat ansiconsole

-- Load script
cd D:\sqlcl\scripts
script helloworld.js

More info:

Using the Script Command

You can load scripts and add them as custom commands.

Purpose: perfect for automating developer tasks.

In this section is you'll learn how to load and execute a script.

Using the Alias Command

Aliases are persistent (as opposed to scripts).

Purpose: perfect for creating shortcuts for SQL statements.

In this section is you'll learn how to create, import/export and execute an alias.

Testing Nashorn scripts with Netbeans IDE

It can be a lot quicker to write and test Nashorn scripts with Netbeans IDE. The advantage is that you don't have to save and rerun your script in SQLcl everytime. It also provides debugging options.

The Nashorn JavaScript engine is included in Java JDK 8.

Basic Nashorn scripts

In this section is you'll learn the basics of writing Nashorn scripts and how to install Netbeans EDI.

Advanced Nashorn scripts to interact with the SQLcl libraries

In this section I've explored the way to test your SQLcl scripts without use of the command-line tool.

Exploring the Java Libraries

SQLcl offers tons of methods in its Java Libraries. In advanced scripts, you might want to use some of them.

In this section I've explored some relevant methods of the Java types.

Real-world examples

Here are some examples to demostrate the power of SQLcl combined with scripts

Example: Installing database objects (via the script command)

I'm actually using this script at my client to automate the installation of database objects in an OTAP environment.

In this section I've explained the way to use this custom command.

Example: Realtime APEX monitoring (via the alias command)

Let SQLcl output your debug & error messages while running an APEX app.

In this section I've explained the way to use this alias.

Useful resources

These are resources I found useful for preparing this project.

OTN

Blogs

Examples

Utilities

sqlcl's People

Contributors

mennooo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.