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 either a Procedure or Sql Editor (See Editor section below). |
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 text field. |
Commit Changes |
Commit all database changes. |
Rollback Changes |
Rollback all database changes. |
Execute Statement |
Execute the statement under the cursor. |
Execute Statement in the Background |
Execute the statement under the cursor in the background. |
Save Statement Result |
Save the Query Result data. |
Execute and Save Statement Result |
Execute the statement under the cursor and save the Query Result data. |
Count Records |
Count the number of records returned by the 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. |
Close Window |
Closes the Sql Editor that is currently showing. |
Databrid supports multiple Sql editor which appear as a set of tabs, one for each editor (Figure 3).
![]() |
Figure 3 - Editors shown as Tabs |
Editors can either be a Procedure or Sql Editor. A Procedure Editor will contain only one executable statement and the entire contents of the editor will be executed when you type Ctrl-Enter (Shortcut for execute in the background) or press the Execute Statement or Execute Statement in the Background buttons.
A Procedure Editor should be used to edit an anonymous PlSql block, a procedure, a package (package header or body only) etc.
A Sql Editor could contain one or more of any type of Sql, PlSql or DDL command. The position of the cursor is used to determine what statement to run. Blank lines above (not necessary at the top of the editor) and below (not necessary at the bottom of the editor) act as separators between statements. Because of this a statement can not contain any blank lines.
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 two valid Sql statements. Databrid would treat this as four different statements (lines 1-2, 4-6, 8-9 and 11). Figure 6 shows 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 - Two 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).
![]() |
Figure 8 - Autocompletion |
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.
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. |
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 Statement | Execute the statement under the cursor. |
Execute Statement in Background | Execute the statement under the cursor in the background. |
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. |
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 and multiple cell selection modes. |
Count Records |
Counts the number of records the query has returned. |
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 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.