SQL Editor
Code Snippets
Code Snippets is a popup reference for Oracle SQL functions and expressions.
To access the Code Snippets window click View | Code Snippets.
In the Code Snippets window, an explanation of the item or function displays in the lower panel. Items can be dragged and dropped into your SQL script.
The code snippets templates are in the Toad directory in Templates.xml. You cannot directly edit the templates. You would need to make modifications via the
View | Options | Editors | Code Snippets page.
Make Code Statement and Strip Code
Statement
The SQL Edit window contains two functions that simplify copying SQL statements from Toad to code development tools such as Delphi, VB, C++, Java, or Perl, and from those code development tools back to Toad. The functions are called Strip Code Statement <CTRL>P and Make code Statement
<CTRL>M, available from the SQL Editor menu.
Make Code Statement
Adds the code development tool syntax to the SQL statement in the SQL Editor, and makes it ready to paste into the development tool code.
When making code statements, rather than changing the code in the SQL Edit window as the Strip Code Statement function does, the Make Code Statement function takes the currently highlighted SQL statement, translates it into the code development tool syntax, and copies it to the clipboard. You can now switch to the code development tool and paste in the results. A message displays in the status panel such as "VB statement copied to the clipboard."
If you have multiple SQL statements in the SQL Editor, highlight the statement you want to make before executing the Make Code Statement function.
Strip Code Statement
Strips off the code development tool syntax from the SQL statement, and places it on the clipboard ready to paste.
If you have multiple SQL statements in the SQL Editor, highlight the statement you want to strip before executing the Strip Code Statement function.
49
Toad for Oracle
Selecting the Code Development Tool
You select the code development tool from the View | Options | SQL Editor |
Make Code | Make Code Format dropdown menu. The Make Code Format dropdown menu lets you select a language syntax for Toad to convert a SQL statement into (Make Code Statement function) and out of (Strip Code
Statement function). Delphi, VB, C++, Java, and Perl are supported. The default selection is VB. You can also create your own language templates.
For information about Creating Make Code language templates, refer to Toad
Help.
The Make Code options page also includes two checkboxes.
Select SQL statement based on cursor position
Default - Unchecked
When this option is selected, Toad will look at the location of the cursor and determine which SQL statement to select.
Strip Code copies to clipboard
Default -Unchecked
When checked, if you choose to strip code, the code you strip is copied to the clipboard so that you can easily undo the operation. If you later strip additional statements, or perform other tasks that place data on the clipboard, the code is overwritten. Only the most recent action is saved.
50
SQL Editor
External Editor
You can use an external editor to edit the SQL Editor contents. To set up, go to the Toad Options | Editors | External Editor Command Line. Enter the drive letter, path, and executable name of the external editor you want, e.g.,
c:\winnt\notepad.exe %S. While in the SQL Editor or Procedure Editor, press
<CTRL><F12> to invoke the external editor, which will start and load up the current Toad Editor contents. Use the external editor, save the contents, quit the external editor.
• You will be prompted to reload the contents of the file only if the
View | Options | Procedure Editor | Reload files when
activating Toad if the file time stamp is changed option is checked.
51