ThatJeffSmith

SQL Developer 4.0 and the Command Line Interface (CLI)

SQL Developer has had a command-line interface of sorts. The primary use cases were for formatting files and running unit tests. However, we wanted to expand the support to include things like generating Carts and running reports.

Instead of just creating a few more one-off interfaces, we kind of started over and built a new CLI from scratch. Random Observation: Developers get very excited when they get to redo something.

Rather than call the main executable, we created a new one. So with SQL Developer version 4, when you run ‘sdcli.exe’ from the BIN directory, you’ll see something like this:

SQL Developer command line options

SQL Developer command line options

Please ignore the yellow highlighted text. That’s an error message that shouldn’t be appearing – a bug that we’ll have fixed for the next EA drop.

It’s the green part that’s more interesting!

Available features

What we have available now are the following features:

  • cart: Database Cart Batch Tasks
  • dba: Basic Batch DBA Tasks
  • format: SQL Format Task
  • migration: Database Migration Tasks
  • reports: Basic Batch Reporting Tasks
  • unittest: Unit Testing Batch Tasks

If I want to know the syntax for running one of these features, simply ask for it. Let’s look at Reports first. I reckon that this might be the most popular use case for the command-line interface.

Running Reports via the Command Line

If I run ‘sdcli64.exe reports’ – it will come back with the usage syntax for the reports option:

How do I run a report?

How do I run a report?

Reports Usage:
reports <command> <command arguments>

Supported commands:
generate -report <path> -db <connection name> -file <output file> [-bind <bname>=<bvalue>]* generates an HTML report

Ok, so let’s run a report and see what happens.

C:\Users\jdsmith\Desktop\sqldeveloper\4.0 EA1\sqldeveloper\sqldeveloper\bin>sdcli64.exe reports generate -report "Demo for 4.0 Take Three" -db HR -file "C:\sqldev4.html"
Success!

Let’s break down that command:

sdcli64.exe reports – this part I hope you get

generate – at this time, generating a report is the only feature exposed, so let’s do that

-report “Demo for 4.0 Take Three” – the name of the report, contains spaces, so I’m quoting it

-db HR – the database connection name to run the report against, requires you to have saved the password

-file “C:\sqldev4.html” – the output, where do we want it and what’s it going to be named

At the moment only HTML is available for output options.

Ok, let’s go look at the output – which in this case is an HTML file.

The HTML output from running my report

The HTML output from running my report

All of the charts should render in HTML WYSIWYG – what you see is what you get. I haven’t played with all 6400 new chart types yet, so let me know if you find one it breaks on.