Quantcast
Channel: sqlcl | ThatJeffSmith
Viewing all articles
Browse latest Browse all 125

Oracle SQLcl: Syntax Highlighting and the Status Bar

$
0
0

With version 21.2 of SQLcl, you have some new, exciting toys to play with! Now, some of you may have heard via the grapevine that the big thing coming to SQLcl was built-in support for vi and emacs when writing or editing your SQL and PL/SQL code.

But before we cover that, I want to cover two additional features.

One, the ability to apply color coding to your text based on our SQL parser.

And two, there’s a new status display bar you can use to see if you have pending transactions, who you’re logged in as, how long your last query took to ran, etc.

Let me show you how that might appear before I show you how to set it up.

As I type, the editor updates the coloring…this might be a bit jarring if you’re a slow typer.

So I’ve got black text with white background comments, green keywords, yellow strings, purple identifiers – thanks Dracula theme makers for the inspiration!

Then at the bottom of my screen I have something telling me my cursor line/char pos, who I’m logged in, the service I’m logged into, my editor mode, my transaction status, and the run time of that last query.

Here are the commands you will need to investigate:

set statusbar
set highlighting
help set statusbar
help set highlighting

Use SET to turn things on or change the configuration, use the ‘help’ to get instructions and examples for doing said SETs.

I’m not going to PRINT that help text here – it’s going to be changing as new versions come out anyway – but I WILL show you my login.sql, so you can use it as a quick start.

Before that, a few more things to know –

  • you can define the ordering of the items shown in the status bar
  • the status bar doesn’t currently, continuously update the statuses
  • the status bar doesn’t currently allow you to add your own custom status items
  • these things are off by default – you must turn them on

My login.sql to setup highlighting and status bar

 set statusbar on
 set statusbar add editmode 
 set statusbar add txn
 set statusbar add timing
 set highlighting on
 set highlighting keyword foreground green
 set highlighting identifier foreground magenta
 set highlighting string foreground yellow
 set highlighting number foreground cyan
 set highlighting comment background white
 set highlighting comment foreground black 

What this looks like, in real time…

Yes, I type real slow like…more like I didn’t know what I was going type until I typed it.

You’ll notice the status bar was changing as I was building the SQL to show the current curpos by line:character number.

Let’s talk about the status bar some more…or better yet let’s demo!

Keep your eye on the status bar items…

So after our ‘big insert’ we have ‘Changes Pending.’

But, as soon as our INDEX is created, it goes back to ‘None.’

Why? Because executing DDL is an implicit COMMIT.

Did you also notice that the text on screen and cursor didn’t start jumping around the screen as I invoked the command history (with my up arrow key?) We’ve FIXED that behavior in this release as well!

This DDL/DML scenario courtesy our AskTom hero, Connor. He’s been helping me in his spare time to ‘beta test’ SQLcl’s new editor features. Thanks Connor!

Wait, wait…what about Windows?

It works/looks exactly the same in your Windows CMD prompt! Our developer on this feature uses Windows by default, and I of course have a Windows corp machine where I do MOST of my work. Everything I’ve shown on my Mac here should appear the same in your MSFT universe.

The post Oracle SQLcl: Syntax Highlighting and the Status Bar first appeared on ThatJeffSmith.


Viewing all articles
Browse latest Browse all 125

Latest Images

Trending Articles



Latest Images