Chat now with support
Chat with Support

Toad for DB2 7.4 - Installation Guide

About Editing SQL

The editor combines a powerful SQL and procedure editor and debugger into a single interface.

Notes:

  • See Editor Shortcut Keys for more information about keyboard shortcuts used in the Editor.
  • Toad has implemented a large script mode to improve performance when opening files larger than 2 MB. By default, when you open a large file, some features such as word wrap, syntax highlighting, and the Script Map are disabled in the Editor. When a large script loads, a message indicates that you are in large script mode in the right margin of the Editor. You can cancel large script mode by clearing the option in Tools | Options | Editor | General.
  • To show the Script Map, Script Results or Group Execute panes for the current Editor window select Editor | Windows | <pane>.

To edit SQL

  1. Select Tools | Edit.

  2. Review the following to help enter SQL:

  3. Click to format the code. See Format SQL for more information.

  4. Right-click a block of code in the Editor to see additional actions available in the context menu. For example, you can turn a line into comment, uppercase or lowercase it, surround with snippet, set numbered bookmark, collapse or expand nodes, send to Query Builder and etc. You can also right-click an object (e.g. a table) and manage it as if in the Object Explorer.
  5. Hold Alt + left-click and drag to select vertical blocks of text in Editor.
  6. Select the block of code in the Editor, and click to validate the syntax.

    Note: Toad undoes any changes to the object and data in the database after executing the script (notice that the Result Sets tab is empty). To modify the object and data, you need to execute the script.

  7. Debug code. See About Debugging SQL for more information.

  8. Click Fetch n rows to specify the number of rows to initially retrieve when executing the query. You can set a default value for this option in Tools | Options | Database | General. See General Database Options.
  9. Click to execute SQL on the current server or multiple servers at one time. See Group Execution of Scripts for more information. In the Editor toolbar, the execute SQL buttons are grouped under . The button will retain the function of the last execute action for the active Editor window. If you switch to another Editor window, the button will change to reflect the last action for that window. For more information, see Execute SQL.

    Tip: To restart a script at a syncpoint, click and enter the syncpoint. See Restart Script from Syncpoint for more information.

  10. Click to tune SQL (available if you purchased Toad Xpert Editions that include the SQL Optimizer for IBM® DB2® LUW or SQL Optimizer for IBM® DB2® z/OS®).

Tips:

  • Toad automatically saves a backup copy of any modified editor file in the Application Data Directory to avoid losing your work. When you restart Toad after an unexpected close, Toad checks the timestamp on the backup file against the original file, and opens the file that has the latest timestamp. The document recovery option is in Tools | Options | Environment | General. See General Environment Options for more information.
  • You can save the current connection, SQL script, executed results, filters, and group execute connections/results (if enabled) in a Toad editor file (.tef). This file format is useful for building scripts that have large result sets that you do not want to continue executing or for saving results when you have not finished building a script.
  • You can create TOADSQLFILE.sql in order to use it's contents as template when opening new Editor window. Save it in a root folder for code snippets. See Code Completion Options for more information.

  • Editor supports floating window mode.
  • The script is automatically checked for syntax errors when executing current statement (F9), checking syntax, changing database, or refreshing the Script Map. The syntax errors are listed in the Script Results pane in the Messages tab.
  • You can edit DB2 Special Registers for a specific Editor connection only. Click and update the registers as needed. When you close the Editor, the edits are canceled.
  • To open a wizard that transfers this script to a remote DB2 for LUW or z/OS server and executes it from there, click .
  • To launch Benchmark Factory to test the scalability of your SQL, click .

Configure Editor Options

You can specify options for the look and behavior of the SQL Editor by using the Toad Options dialog.

To configure Editor options

  1. Select Tools | Options.
  2. To specify one of the following options, select the corresponding page in the Options dialog.

    Option Description

    Page in Options Dialog

    Display the tabs for the current connection only when using Tabbed windows

    Select Environment | Interface

    Change background color of the Editor Select Editor | General
    Use connection color as background color Select Editor | General
    Position Editor tab headers vertically Select Environment | Interface

    Set options to display line numbers, line modifications, and general text formatting

    Select Editor | General 

    Specify options to automatically replace typed text with the correct substitution text

    Select Editor | Auto-replace

    Customize code formatting options including headers and layout characteristics

    Select Editor | Formatter

 

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating