New Feature: Easy one-click execution of SQL in Console output against a Data Source

In almost every application we write and run, we have SQL being executed against a server.  When debugging our applications, we often set our logging to display the SQL being executed, and just as often have to execute that SQL to insure that the results of the query is indeed what we are seeing in the debugger as being returned.  This has been such a part of life as an enterprise developer for the past 25 years, that I never thought on how to make it easier to just now.

What I propose, is that IDEA support some simple mark-up tag, that identifies SQL, such as <sql></sql>.  Then they extend the Console to recognize this tag, identifying the contents as executable sql.  Additionally, the Console should have a pull-down to allow the user to choose between defined Data Sources, as the default target of executed SQL.  Now, the simple part should be, when you click on the SQL in the log, it gets executed against the selected data source and comes up in a Data Source console.

In one simple fell swoop, we break this historical chain of copy paste into data base UI front ends to see what is going on.

I was not sure if this type of integration between the consoles content area, its controls, and the data sources would be a very easy thing to do as a plug-in.  But if some of you think it is, maybe I should take a shot at it first before asking the IntelliJ guys to add it as a feature.

One additional feature, that I think would be excellent, would be to expose a simple api that allows a plug-in to register for the execution requests when a user clicks on the SQL, so we can add plug-ins to send the sql to our favorite third party UI tool.  In my case, I use Oracle's SQL Developer a lot, and I would try and see if I could message over a sql request to it via an IDEA plug-in (I have no idea if that is possible, but as I work on Mac OS X, there is often some simply integration between apps using the Services menu.

BTW, the doc says that IDEA already supports execution of "Injected SQL Statements from the Editor", so similar support exists for SQL in the Code Editors.  This therefore may be a very simple extension of that existing infrasturcture.

0
4 comments

I'm currently scrolling through the existing extension points a bit and I've seen one that maybe could be helpful for you if you want to do it as a plugin.
From a first look, com.intellij.execution.filters.ConsoleFilterProvider looks like what you need to highlight and link the SQL in console output I think.

0

Excellent, thank you.  Now I just have to find API to get the list of data sources, add a combo box to the console UI and execute SQL via a specified data source in a data source console.  A trip of 5000 miles begins with the first step.  Tx.

0

Just guessing here again, but maybe you have to make an action group with popup="true" and some sub-actions and add it to the right action group for where you want it to appear like ConsoleView.PopupMenu. Or you could add it to the custom console actions via ConsoleViewImpl.addCustomConsoleAction().

Data sources you probably get via DataSourcesManager.getDataSources() I'd guess.

0

Wonderful.  Thanks.  Now I just have to get the time to do it :)

0

Please sign in to leave a comment.