The SQL Editor tab allows you to write and run SQL and PLSQL. The tab provides the ability to use one of more syntax highlighting editors with automatic case adjustment for keywords. Provided with each editor is a table for displaying SQL query results and a text output area to display output (such as Oracle DBMS_Output). Jobs can be run in the background allowing for the execution of multiple statements at any given time.
This section is broken down into four areas: Tool Bar, Editors, Query Result, Output.
![]() |
Figure 1 - Databrid showing the SQL Editor tab. |
The buttons in the tool bar from left to right are:
![]() |
Figure 2 - SQL Editor Tool Bar |
New Editor | This allows you to create new editor. Clicking the icon will set the new editors connection to be the same as the current editors connection. Clicking the down arrow beside the icon will allow you to select a connection to use. | ||||||
Open Editor | Allows you to open a file in a Procedure or Sql Editor. | ||||||
Save Editor | Save the current editor | ||||||
Save All Editors | Save all of the editors | ||||||
Copy Text | Copy the selected text field text or table selection into the clipboard. | ||||||
Cut Text | Cut the selected text field text into the clipboard. | ||||||
Paste Text | Paste the clipboard contents into the field. | ||||||
Commit Changes | Commit all database changes. | ||||||
Rollback Changes | Rollback all database changes. | ||||||
Execute Statement | Execute the statement under the cursor. | ||||||
Execute Editor as a Statement | This treats the entire contents of the editor as a statement and executes this statement. | ||||||
Count Records | Count the number of records returned by query. | ||||||
Describe | Show information about the word containing the cursor in a schema browser view. For example if the cursor was in the word emp and emp is a table then information about the table emp would be displayed. | ||||||
Sql History | Show a list of Sql statements that have previously been successfully run. | ||||||
Cancel Job | Cancel the statement previously run in the background job from the Sql Editor. | ||||||
Connection | This allows you to change the connection used when executing commands in the editor. Each editor has its own or shares a connection.
Figure A shows a typical popup menu for an instance of Databrid that has connections for only one type of database. Figure B shows the
popup menu if there are connections for both Oracle and MySql. Note that the current active connections are shown on this top level menu
to make reuse easier. The Connection, Oracle, MySql sub-menus show a list of one or more connections not currently used (Figure C).
|
||||||
Database | Allows the user to select the database to be used for the connection (MySql only). This is the equivalent of using the USE command. | ||||||
Close Window | Closes the Sql Editor that is currently showing. |
Databrid supports multiple Sql editors which appear as a set of tabs, one for each editor (Figure 3).
![]() |
Figure 3 - Editors shown as Tabs |
Each editor has a connection associated with it. Connections can be just for the editor or shared. The current connection is shown in the toolbar (under the connection heading) and can be changed at any stage. Commands in the editor can executed as the statment under the cursor (separated from other connections by blank lines) or the entire editor.
Figure 4 Shows how three valid Sql statements. The statements are on lines 1-2, 4-8 and 10. Performing an execute on lines 1-3 will execute the first statement, lines 4-9 will execute the second statement and lines 10-11 will execute the third statement.
Figure 5 shows only three valid Sql statements. Databrid would treat this as four different statements (lines 1-2, 4-6, 8-9 and 11). Figure 6 shows how comments can be used to separate parts of a statement. The second statement in this figure is now on lines 4-9. Performing an execute on any lines from 4 to 10 will execute on this statement.
![]() |
![]() |
![]() |
Figure 4 - Three Valid Sql Statements | Figure 5 - Three Valid Sql Statements | Figure 6 - Three Valid Sql Statements |
The result of an execution of any Select statement is displayed in the Query Result tab (see the Query Result section below). If you execute any statement that does an Oracle DMBS_Output then the output of this is shown in the Output tab (see the Output section below).
Each SQL Editor has its own Query Result and Output areas.
If the cursor stops on a word for more than 1.5 seconds that word and all other instances of the word are highlighted. Highlight is just a visual tool to help you identify all instances of a particular word, it has no impact on execution of a statement. Figure 7 shows an example of word highlighting.
![]() |
Figure 7 - Word Highlighting |
Autocompletion is a feature that helps you write sql statements. When you type a table or view name or an alias followed by a dot and pause for half a second a list of columns will appear (See figure 8). If you have not paused but still want autocompletion then the menu can be displayed by pressing ctrl-space.
![]() |
Figure 8 - Autocompletion |
In the autocompletion menu you can select a word by using the up and down arrow and/or the page up and page down button. Pressing enter will place the currently selected autocompletion word into the editor. Pressing space, escape or moving off of the word will cancel the autocompletion.
Another method of selecting an autocompletion word is to partially type the word. As you type the word in the autocomplete list closest to what you have typed will be selected. When you press enter the currently typed word will be replaced with the autocompletion word.
The information displayed in the autocompletion popup is cached within Databrid to speed up response times. Because of this it can get out of date with the database. To refresh the data displayed as part of autocompletion select the "Reload Cache" item in the Database menu.
Oracle also does autocompletion for package functions and procedures. Typing the packaging name and a dot will display a list of function and procedure names along with their parameter and/or return values.
It is possible to bind in values by specifying the bind as a : followed by a name, i.e. :name and :salary. When the statement is executed you will be prompted for values of the fields. If the same bind is used more than once in a Sql statement it will only be prompted for once but the prompted value will be used for each instance.
The example in figure 9 illustrates how to use bind variables.
![]() |
Figure 9 - Variable Binding |
When the example in is executed the dialog in Figure 10 is displayed (Note that salary appears twice in the Sql Statement but only once in the Bind Variable dialog). Each consecutive time the statement is executed the dialog will be displayed and any previous values entered will also appear. If you do not want to bind any values (Databrid has mistaken the: or & for a bind when it really isn't) then check the "Ignore Binds" checkbox. With this checked the binds will be ignored.
![]() |
Figure 10 - Bind Variable Entry |
An alternative to binding is substitution. Substitution is specified by using a & followed by a variable name, i.e. &name &salary. Figure 11 shows an example of variable substitution.
![]() |
Figure 11 - Variable Substitution |
When the Sql statement from Figure 11 is executed the same dialog will be displayed that was used for Bind Substitution (Figure 10). This is where the difference between binding and substitution can be best shown. When the statement is run the values from the Bind Dialog are used to replace the substitution variables.
So what would actually be run for the statement in Figure 11 is shown in Figure 12 (your statement is not updated, the changes are in the database only). As can be seen from the statement it won't actually work, line four would create an error since the string CLARK is not quoted. To get this statement to work you need to change the Bind Dialog variable name from CLARK to 'CLARK'.
![]() |
Figure 12 - Statement after Substitution |
If you want to provide values for assignment or conditions then bind variables are best suited. If you want to change the Sql statement itself then substitution is the best way. Figure 13 shows a statement where the "where" clauses condition is the substitution. If a > is entered in the Bind Dialog for the value of condition then it would be the equivalent of Figure 14 and a < would be the equivalent of Figure 15.
Figure 13 - Before Substitution | Figure 14 - Using Substitution of a > | Figure 15 - Using Substitution of a < |
Right clicking on the editor background will pop up the menu shown in figure 16 and the “Edit” sub menu shown in figure 17.
![]() | ![]() |
Figure 16 - Editor Menu | Figure 17 - Editor Edit Sub Menu |
The commands on the editor right click menu(Figure 16) are as follows:
Copy | Copy the selected text to the clipboard. |
Cut | Cut the selected text to the clipboard. |
Paste | Paste the clipboard to the editor. |
Redo | Redo the changes undone using the undo command. |
Undo | Undoes the changes just made. |
AutoCase Disable/Enable | Enable or Disable the AutoCase functionality. AutoCase will automatically adjust the case of your statements depending on whether they are key words, functions or other text. |
Edit | Displays the sub menu of edit commands, see below. |
Find Text | Opens a find dialog to search for a given text string. |
Find Next | If text is selected then this finds the next occurrence of the selected text otherwise it finds the next occurrence of the previously searched for text from either this command or the Find Text Command. |
Find Previous | Same as the Find Next command but this searches in the opposite direction. |
Replace Text | Opens the replace text dialog where one string can be replaced with another. |
Select All | Selects all of the text in the editor. |
Commit Changes | Commit the changes made to the database. |
Describe | Show information about the word containing the cursor in a schema browser view. For example if the cursor was in the word emp and emp is a table then information about the table emp would be displayed. |
Execute Editor and Save | Executes the entire contents of the editor and opens the save query result dialog. |
Execute Editor as Statement | Executes the entire contents of the editor as a statement. |
Execute Statement at Cursor | Execute the statement under the cursor as a statement. Statement can be separated by blank lines |
Execute and Save Statement | Execute the statement under the cursor and save the Query Result data. |
Rollback Changes | Rolls back changes made to the database. |
The commands on the editor right click Edit sub menu (Figure 17) are as follows:
Lower Case Text | Changes the selected text to lower case. |
Upper Case Text | Changes the selected text to upper case. |
Delete to End of Word Boundary | Deletes from the current cursor position to the end of the word that contains the cursor. |
Delete to Start of Word Boundary | Deletes from the current cursor position to the start of the the word that contains the cursor. |
Go to End of Word | Goes to the end of the word that contains the cursor. |
Go to Start of Word | Goes to the start of the word that contains the cursor. |
Select to End of Word | Selects to the end of the word that contains the cursor. |
Select to Start of Word | Selects to the start of the word that contains the cursor. |
Export Text | Exports the selected text to a file. |
Import Text | Inserts text from a specified file into the editor. |
Import Text to Clipboard | Inserts text from a specified file into the clipboard. |
Format | Formats the Sql and/or PlSql. If text is selected then only the selected text will be formatted otherwise the entire contents of the editor will be formatted. |
The Query Result area contains a table for displaying the results of queries and explain plans. The table can easily be scrolled through to examine the data presented.
Right clicking on a table item presents the following menu.
![]() |
Figure 18 - Right Click table Menu |
The commands on the editor right click menu are as follows:
Copy | Copy the selected text to the clipboard. |
Copy Current Table Cell | Copies only the focus cell, not the entire row or selection. |
Cut | Cut the selected text to the clipboard. This is disabled for the table menu. |
Paste | Paste the clipboard to the editor. This is disabled for the table menu. |
Toggle Selection Mode | Toggles between row selection, multiple row selection and multcell selection modes. |
Count Records | Counts the number of records the queryreturned. |
Save Statement Result | Save the result of the query as a CSV (comma delimited file) or insert statements to the clipboard or to a file. |
The buttons in the tool bar from left to right are:
![]() |
Figure 2 - SQL Editor Table Tool Bar |
Change Selection Mode | Toggles between the select row, select multiple rows or select multiple cells mode. |
Copy Row | Copies the currently selected row into the clipboard. |
Copy Current Cell | Copies the current cell. |
Save Table Results | Saves the results currently displayed in the Query Result. |
Edit/View row | Opens the Edit/View row dialog. |
Add New Row | Takes you to the Edit row dialog to create a new row. |
Delete Selected Row | Delete the currently selected row. |
Save Changes to Database | Writes the changes made to the database, a commit is not done. |
Undo Unsaved Changes | Undo changes that have not been written to the database. |
The Output area captures output from the Oracle DBMS_Output command. Output is only captured if the "Enable DBMS_Output" check box is checked. This tab also has a clear button for clearing the contents of the Output. This area can also be used as a temporary storage area.