xml spy
Previous  Top  Next

Query Pane: Description and Features


The Query pane is an intelligent SQL editor for entering queries to the selected database. After entering the query, clicking the Execute command of the Database Query window executes the query and displays the result and execution messages in the Results/Messages pane. How to work with queries is described in the next section, Query Pane: Working with Queries. In this section, we describe the main features of the Query pane:

 

SQL Editor icons in the Database Query toolbar
SQL Editor options
Auto-completion of SQL statements
Definition of regions in an SQL script
Insertion of comments in an SQL script
Use of bookmarks

 

 

SQL Editor icons in the Database Query toolbar

The following icons in the toolbar of the Database Query window are used when working with the SQL Editor:

 

ic_dbqry_execute

Execute

Executes currently selected SQL statement. If script contains multiple statements and none is selected, then all are executed.

ic-sql-import

Import SQL File

Opens an SQL file in the SQL Editor.

ic-sql-export

Export SQL File

Saves SQL queries to an SQL file.

ic_undo

Undo

Undoes an unlimited number of edits in SQL Editor.

ic_redo

Redo

Redoes an unlimited number of edits in SQL Editor.

ic-sql-options

Options

Open the Options dialog of SQL Editor.

ic-sql-openinDBS

Open SQL Script in DatabaseSpy

Opens the SQL script in Altova's DatabaseSpy product.

 

 

SQL Editor options

Clicking the Options icon in the Database Query toolbar pops up the Options dialog (screenshot below).

 

dbquery_options

 

The key settings are as follows:

 

SQL Editor: Options for toggling Auto-Completion and syntax coloring on/off, the tab-width and retrieval specifications. The Auto-Completion feature works by suggesting, while you type, relevant entries from various SQL syntax categories. It is available for the following databases: for the following databases: MS SQL Server 2000 and 2005, MS Access 2003, and IBM DB2 v.9. When the Auto-Completion option is switched on, the Auto-Completion window (screenshot below) appears, containing suggestions for auto-completion. Select the required entry to insert it. Note the buttons at the bottom of the window. The Context-Sensitive Suggestion button sets whether only entries that are relevant to the context are displayed or all possible entries with that spelling. The Single Mode button enables you to click a category button to select only that category. The Set All Categories button selects all categories. You can then deselect a category by clicking its button. The Clear All Categories button deselects all categories. The other buttons are the various category buttons.
 
DBQueryAutoCompletion

 

SQL Editor | SQL Generation: StyleVision generates SQL statements when you drag objects from the Browser pane into the Query pane. Options for SQL statement generation can be set in the SQL generation tab. Use the Database Kind drop-down list to select a database kind and set the statement generation options individually for the different database kinds you are working with. Activating the Apply to all databases check box sets the options that are currently selected for all databases. Options include appending semi-colons to statements and using all-caps.
SQL Editor | Text Font: Options for setting the font style of the text in the SQL Editor.
SQL Editor | Result View: Options to configure the Result tab.
SQL Editor | Grid Font: Options for setting the font style of the text in the Result Grid in the Results tab.
General | Encoding: Options for setting the encoding of new SQL files and of existing SQL files for which the encoding cannot be detected. (If the encoding of existing SQL files can be detected, the files are opened and save without changing the encoding.)

 

 

Definition of regions in an SQL script

Regions are sections in SQL scripts that are marked and declared to be a unit. Regions can be collapsed and expanded to hide or display parts of the script. It is also possible to nest regions within other regions. Regions are delimited by --region and --endregion comments, respectively, before and after the region. Regions can optionally be given a name, which is entered after the -- region delimiter (see screenshot below).

 

DBQueryRegions

 

To insert a region, select the statement/s to be made into a region, right-click, and select Insert Region. The expandable/collapsible region is created. Add a name if you wish. In the screenshot above, also notice the line-numbering. To remove a region, delete the two --region and --endregion delimiters.

 

 

Insertion of comments in an SQL script

Text in an SQL script can be commented out. These portions of the script are skipped when the script is executed.

 

To comment out a block, mark the block, right-click, and select Insert/Remove Block Comment. To remove the block comment, mark the comment, right-click and select Insert/Remove Block Comment.
To comment out a line or part of a line, place the cursor at the point where the line comment should start, right-click, and select Insert/Remove Line Comment. To remove the line comment, mark the comment, right-click and select Insert/Remove Line Comment.

 

 

Use of bookmarks

Bookmarks can be inserted at specific lines, and you can then navigate through the bookmarks in the document. To insert a bookmark, place the cursor in the line to be bookmarked, right-click, and select Insert/Remove Bookmark. To go to the next or previous bookmark, right-click, and select Go to Next Bookmark or Go to Previous Bookmark, respectively. To remove a bookmark, place the cursor in the line for which the bookmark is to be removed, right-click, and select Insert/Remove Bookmark. To remove all bookmarks, right-click, and select Remove All Bookmarks.

 

 


See also:

 

 


 

 


Previous  Top  Next

© 2008 Altova