DatabaseSQLHistory

SQL History

Discussion

Issue 133811

Description

For 6.5 we want to show statements that have been executed and also make it easier for users to re-execute SQL statements.

There are two proposals:

  1. Show a list of SQL statements previously executed for a selected connection.
    1. Allow a user to choose a connection from a dropdown and insert statement(s) from a unique list of individual SQL statements into the SQL editor at the cursor location
    2. Save by serializing the SQL statements so they can be recalled for another IDE session. Statements are saved when a connection is closed or the SQL editor is closed
    3. A limited number of statements (5000) will be saved but this can be user-configurable through the Options dialog.
    4. Also allow statements to be filtered: match an expression entered in a textfield (matchbox)
  2. (M2) Update the SQL Editor to recall the previous (or next) contents of the SQL Editor using navigation buttons
    1. the contents of the editor are replaced when switching to a previous or next "screen"
    2. History of all SQL in the order executed will be available

The first proposal is targeted for Milestone 1, while the second proposal will be targed for Milestone 2.

Use cases

Part I

  • User opens a connection
  • Result: SQL that was saved in a serialized file is deserialized and stored in an ArrayList in memory. The ArrayList of objects each of which contain a URL and an SQL statement.


  • User wants to execute some SQL: opens an SQL file and executes SQL statements
  • Result: SQL statements are added to the ArrayList


  • Open an SQL file and execute SQL statements then wants to see the SQL that had been executed: user opens the History dialog using the SQL Editor toolbar button, choosing a context menu in the SQL Editor or shortcut key Ctrl-Alt-h.
  • Result: SQL statements appear in the History dialog. The default maximum number of statements will be 5000 but is user-configurable in Options


  • User disconnects from a connection or closes the SQL Editor.
  • Result: ArrayList that stores SQL history is written to disk or replaces existing serialized file


  • User wants to insert previously executed SQL into the editor at the cursor location in the SQL Editor.
  • Open the History dialog using the SQL Editor toolbar button and selects one or more statements then click the Insert button. The dialog must be reopened to insert more statements


  • User wants to find then insert previously executed SQL into the editor at the cursor location in the SQL Editor.
  • Open the History dialog, enter a matching string in the Match SQL textfield and select the matching statement(s) then click the Insert button.


  • User wants to see the history after closing and reopening NetBeans: user opens the History dialog using the toolbar button in the SQL Editor.
  • Result: the list of previously executed statements is listed.



Part II

  • In the SQL Editor, revert back to previously edited SQL.

Click the left (or previous) navigation arrow at the top of the SQL Editor and the SQL Editor's contents are replaced with the previous SQL statement executed


  • In the SQL Editor, go forward to the next edited SQL.

Click the right (or next) navigation arrow at the top of the SQL Editor andthe SQL Editor's contents are replaced with the next SQL statement executed


UI proposal

Part 1 of the History feature:


To retrieve SQL History, a dialog will be used. The dialog is opened by clicking a History button on the SQL Editor toolbar or typing a keyboard shortcut.

To find matching SQL history, the dialog will have a textfield and a Search button. Multiple SQL can be selected. Pressing the Insert button closes the dialog and inserts the SQL at the cursor in the Editor.

For statements that take up more than one line, only the first line will appear in the dialog. Mousing over the line will popup the full SQL statement.



+--------------------------------------------------------------+
| SQL History                                                  |
+--------------------------------------------------------------+
|  ''' Connection_ V        Matching SQL '''___  [Search ]      |
|                                                              |
|                                                              |
|  SQL Executed                                                |
|  +-----------------------------------------------------+     |
|  |SQL 1                                                |     |
|  |SQL 2                                                |     |
|  |SQL 200                                              |     |
|  +-----------------------------------------------------+     |
|                                                              |
|                                  [[Insert  |  Insert ]] [[Cancel ]     |
|                                                              |                                                     
+--------------------------------------------------------------+


Part 2 of the History feature: (M2)

Allow a user to re-execute a statement that had been previously executed by flipping to a previous or next SQL statement executed using navigation buttons. Also, a dropdown (with scrollbars) for quick selection of prior SQL Editor contents

+----------------------------------------------------+
| SQL Editor                                         |
+----------------------------------------------------+
| <- -> '''V_     Connection '''_ V_                   |
+----------------------------------------------------+
|                                                    | 
|                                                    |
|                                                    |
+----------------------------------------------------+


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo