Updated 5 January, 2023

In this post, I’m going to show you how to:

  • ‘cancel’ yourself out of a buffer/command
  • cancel a query
  • ctrl+c yourself back to the shell/cmd prompt

Starting over on your query/script

Ctrl+C will kill you out of SQLcl completely if you’re in the editor. This is a bug on one of the components we’re using (JLINE), and we have a fix scheduled for SQLcl 19.2. But in the meantime, using the ESC key will provide you all the relief necessary.

You start typing, and at some point, you realize, there’s no fixing this, let’s just start over.

Hit ESC to exit the editor, and we’ll leave the buffer contents instact

Again, we hope to have this working with Ctrl+C in version 19.2 of SQLcl.

Update: New Escape Sequence as of Version 21.2

Ctrl + G will get you out of the editor/buffer.

You can see this if you run ‘show keymap’ –

‘viins’ mode is the default when you’re inputting your SQL or PL/SQL code.

Cancelling a query

You’ve successfully submitted your query or anonymous block to the database. Now we want to cancel it. Ctrl+C will send that request.

Now at that point, it’s up to the jdbc driver and the database to decide how and WHEN to handle that request.

Here’s an example.

Issue your Ctrl+C and wait.

I’m tired of waiting just get me out of here already

Just hit ctrl+c, again.

Yes, I know, I’m not the best typist out there.

Making this more transparent going forward

We also plan in version 19.2 to print status messages to the window. For example, when you send the query cancel, we’ll register that and let you know we’re working on it, so you don’t get frustrated and hit the button again.

I’m also told that in 19.2 with the new JLINE toys, we’ll be able to do some wicked-cool vi integration.

Author

I'm a Distinguished Product Manager at Oracle. My mission is to help you and your company be more efficient with our database tools.

10 Comments

  1. Pavol BabeL Reply

    New 22.4 on MACOS 12 here. ESC nor working, just wondering if was designed also for MACOS or if we have different shortcut here.
    Anyway, CTRL+C works OK, there is just still need for double pressing shortcut… And still missing some message that my script/query has been cancelled…

    • The new sequence on your Mac is Control+G

      I’ve updated this post to reflect the changes, thanks for the heads-up!

  2. On Windows 10 in the Windows Terminal under PowerShell the issue is still present.
    Esc doesn’t work. Ctrl+C aborts sqlcl and exits to the shell prompt.

    • Hmm, I also experience this problem. Environment: Windows 10 Pro 21H1, native CMD, SQLcl 20.4. If I press Ctrl-C on the “SQL>” prompt, in the SQL command editor or on an ACCEPT prompt, it kills SQLcl completely.

    • If you mean TRACEONLY, then not till at least version 20.2

      otherwise autotrace already works

Reply To Andriy Cancel Reply