+ All Categories

Download - Toad Users Guide

Transcript
Page 1: Toad Users Guide

USER’S GUIDE

Page 2: Toad Users Guide

This guide contains proprietary information, which is protected by copyright. The information inthis guide is subject to change without notice and does not represent a commitment on the part ofQuest Software. The software described in this guide is furnished under a license or nondisclosureagreement. This software may be used or copied only in accordance with the terms of thisagreement. No part of this guide may be reproduced or transmitted in any form or by any means,electronic or mechanical, including photocopying and recording, for any purpose other than thepurchaser’s personal use without the written permission of Quest Software, Inc.

© 2000 Quest Software, Inc. All Rights Reserved.Quest™ is a trademark of Quest Software, Inc.

Quest Software, Inc.8001 Irvine Center Drive

Irvine, CA 92618USA

Tel. 949-754-8000 / Fax [email protected]

[email protected]

TOAD™ is a trademark of Quest Software, Inc. Other trademarks and registered trademarks usedin this guide are the property of their respective owners.

Page 3: Toad Users Guide

Contents

C O N T E N T S

TOAD User’s Guide

INTRODUCTION.............................................................................................................................................7

LOGON/LOGOFF............................................................................................................................................9

LOGON OPTIONS ............................................................................................................................................12CONNECTING TO PERSONAL ORACLE.............................................................................................................17END CONNECTION..........................................................................................................................................17

SCHEMA PREPARATION...........................................................................................................................19

BASIC NAVIGATION ...................................................................................................................................21

MOUSE...........................................................................................................................................................21KEYBOARD ....................................................................................................................................................26HOTKEYS – ADDING/ALTERING......................................................................................................................28RIGHT-CLICK MENUS ....................................................................................................................................30

Location of Right-Click Menus .................................................................................................................31

MAIN TOAD WINDOW TOOLBAR...........................................................................................................35

SQL EDITOR..................................................................................................................................................37

TOOLBAR BUTTONS........................................................................................................................................38SHORTCUT KEYS............................................................................................................................................40USING THE SQL EDITOR................................................................................................................................44

Selecting a table to edit .............................................................................................................................44Commit ......................................................................................................................................................47Explain Plan..............................................................................................................................................49Offline Text Editor.....................................................................................................................................52Recall and Add SQL..................................................................................................................................55

OPTIONS FOR THE SQL EDITOR .....................................................................................................................60EXECUTING STATEMENTS ..............................................................................................................................65

Execute SQL Scripts..................................................................................................................................66Table/View Aliases ....................................................................................................................................67

CONFIGURING THE EDITOR ............................................................................................................................69EDITOR OPTIONS............................................................................................................................................78

General Options ........................................................................................................................................79Highlighting ..............................................................................................................................................89Key Assignments........................................................................................................................................95

Page 4: Toad Users Guide

4 TOAD User’s Guide

Auto Replace ............................................................................................................................................ 97Code Templates ........................................................................................................................................ 99

RIGHT-CLICK MENU ................................................................................................................................... 101SQL RESULTS GRID.................................................................................................................................... 102

Results Grid Right-Click Menu .............................................................................................................. 104OPTIONS FOR THE DATA GRIDS................................................................................................................... 117LONG AND LONG RAW........................................................................................................................... 121TIME VALUES.............................................................................................................................................. 124SQL TEMPLATES ........................................................................................................................................ 125DBMS_OUTPUT TO DEBUG PL/SQL CODE ............................................................................................. 127MAKE CODE STATEMENT AND STRIP CODE STATEMENT............................................................................ 128OPTIONS FOR THE EDITORS ......................................................................................................................... 131SQL EDITOR TASKS.................................................................................................................................... 134

PROCEDURE EDITOR.............................................................................................................................. 147

TOOLBAR BUTTONS .................................................................................................................................... 148SHORTCUT KEYS......................................................................................................................................... 151USING THE PROCEDURE EDITOR ................................................................................................................. 153NAVIGATOR LIST ........................................................................................................................................ 162

Navigator buttons................................................................................................................................... 162OPTIONS FOR THE PROCEDURE EDITOR....................................................................................................... 163RIGHT-CLICK MENU ................................................................................................................................... 168SOURCE CODE MANAGEMENT .................................................................................................................... 169PROCEDURE EDITOR TASKS ........................................................................................................................ 171

PL/SQL DEBUGGER.................................................................................................................................. 183

REQUIREMENTS........................................................................................................................................... 185To run the PL/SQL Debugger ................................................................................................................ 188To Activate the PL/SQL Debugger Registration Key ............................................................................. 188

DEBUG TOOLBAR BUTTONS......................................................................................................................... 189DEBUG SHORTCUT KEYS............................................................................................................................. 194USING THE DEBUGGER................................................................................................................................ 195THE STATUS PANEL INDICATORS ................................................................................................................ 197OPTIONS MENU FOR DEBUGGING ................................................................................................................ 198THE DOCKABLE WINDOWS ......................................................................................................................... 202

Breakpoints ............................................................................................................................................ 204Watches .................................................................................................................................................. 210Call Stack ............................................................................................................................................... 216DBMS_OUTPUT.................................................................................................................................... 217

DEBUG FUNCTIONS ..................................................................................................................................... 221PREPARING PL/SQL CODE FOR PRODUCTION............................................................................................. 229

SCHEMA BROWSER................................................................................................................................. 231

TOOLBARS .................................................................................................................................................. 232RIGHT-CLICK MENUS ................................................................................................................................. 235

Page 5: Toad Users Guide

Contents 5

USING THE SCHEMA BROWSER ....................................................................................................................237OPTIONS FOR THE SCHEMA BROWSER .........................................................................................................241TABLES ........................................................................................................................................................251INDEXES.......................................................................................................................................................283PROCEDURES ...............................................................................................................................................287TRIGGERS.....................................................................................................................................................293SEQUENCES..................................................................................................................................................296VIEWS..........................................................................................................................................................299SYNONYMS ..................................................................................................................................................307CONSTRAINTS ..............................................................................................................................................310DB LINKS.....................................................................................................................................................314JAVA ..........................................................................................................................................................316SCHEMA BROWSER TASKS...........................................................................................................................317

OTHER TOAD OPTIONS AND FEATURES ...........................................................................................321

SQL MODELER ............................................................................................................................................322OBJECT SEARCH...........................................................................................................................................341DDL REPORTS.............................................................................................................................................343MASTER/DETAIL RECORD BROWSER............................................................................................................345PRIVILEGES..................................................................................................................................................347REBUILD TABLE...........................................................................................................................................349TOAD SECURITY.........................................................................................................................................351VIEW MENU.................................................................................................................................................358OPTIONS MENU............................................................................................................................................359

General Options ......................................................................................................................................360Oracle Options ........................................................................................................................................362Startup Options .......................................................................................................................................365Files Options ...........................................................................................................................................367Source Control Options...........................................................................................................................369Printing Options......................................................................................................................................371

TUNING SERVER STATISTICS........................................................................................................................372SGA TRACE OPTIMIZATION.........................................................................................................................375ESTIMATE TABLE SIZE .................................................................................................................................377ESTIMATE INDEX SIZE..................................................................................................................................379PROFILER ANALYSIS (ORACLE 8I ONLY)......................................................................................................380OBJECT BROWSER (ORACLE 8 OR 8I ONLY) .................................................................................................392

Objects Panel ..........................................................................................................................................392Details Panel...........................................................................................................................................395

TROUBLESHOOTING................................................................................................................................403

FREQUENTLY ASKED QUESTIONS ................................................................................................................403SQL*NET/NET8 INSTALLATION PROBLEMS ................................................................................................404

UPGRADES...................................................................................................................................................407

TOAD ADD-ON MODULES .......................................................................................................................409

Page 6: Toad Users Guide

6 TOAD User’s Guide

QUEST SOFTWARE SQLAB TUNER/XPERT .................................................................................................. 410QUEST SOFTWARE SQL IMPACT ................................................................................................................. 411REVEALNET PL/FORMATTER...................................................................................................................... 412REVEALNET KNOWLEDGE BASE................................................................................................................. 413

QUEST SOFTWARE PRODUCTS AND SOLUTIONS.......................................................................... 415

DEVELOPMENT & DEPLOYMENT................................................................................................................. 416SQL Development................................................................................................................................... 416Deployment ............................................................................................................................................ 416Application Change Management .......................................................................................................... 417

PRODUCTION SUPPORT................................................................................................................................ 417High Availability .................................................................................................................................... 417Enterprise Monitoring............................................................................................................................ 418Database Management........................................................................................................................... 418

INFORMATION AVAILABILITY ..................................................................................................................... 419Enterprise Report Management ............................................................................................................. 419Output Management............................................................................................................................... 419

QUEST SOFTWARE INFORMATION.................................................................................................... 420

TECHNICAL SUPPORT .................................................................................................................................. 421

INDEX........................................................................................................................................................... 422

Page 7: Toad Users Guide

Introduction

TOAD

TOAD is a powerful low-overhead tool built around an advanced SQL and PL/SQLeditor. It was designed from the developer’s perspective, and the result is an easy touse, fast, and effective interface. The GUI object browsers provide quick access todatabase objects.

You don’t have to be a PL/SQL expert to access database objects when you’re usingTOAD. You can view the Oracle Dictionary, tables, indexes, stored procedures, andmore-- all through a multi-tabbed browser.

PL/SQL script writers can use the advanced editing features to save time andincrease productivity. Code can be created from shortcuts and code templates. Evencreate your own code templates.

Use TOAD to� Create, browse, or alter objects (tables, views, indexes, etc.) including Oracle8

TYPE objects� Graphically build, execute, and tune queries� Edit, debug, and profile “stored procedures” including procedures, functions,

packages, and triggers� Search for objects� Find and fix database problems with constraints, triggers, extents, indexes, and

grants

Page 8: Toad Users Guide

8

This guide is a how-to and reference for new users and users already familiar withTOAD. The guide does not cover every TOAD Window, Option, and Function. Theguide covers the following windows:� SQL Editor� Procedure Editor� Schema Browser� PL/SQL Debugger (an optional feature)

Once you are comfortable navigating around a few of these windows you’ll discoverthat the other TOAD windows have a similar design. The manual also covers thefollowing major topics:� logon/logoff� navigation and shortcuts� additional options in other TOAD windows� optional add-on modules

Note that this User Guide was prepared in February, 2000. New or changed TOADfeatures since February, 2000, are not reflected in this version of the TOAD UserGuide.

Note that colors are presented in the .PDF, which commercial TOAD users candownload from www.quest.com. The printed version of the TOAD User Guidemanual is printed in black and white, so the color differences are not alwaysdistinguishable.

For details on installing and uninstalling TOAD, refer to the TOAD Getting StartedGuide.

Remember, you can always access TOAD Help while in TOAD by pressingthe F1 Key.

Page 9: Toad Users Guide

Logon/Logoff

When you Start TOAD a Login screen displays. The screen lists your previousconnections (server, user, and the date and time of the connection). You can create anew connection to Oracle or select from a list of previous connections. If the BuildOracle Alias List checkbox is checked, TOAD will fill the database dropdown withthe database aliases listed in the TNSNAMES.ORA file. If you double-click to selecta previous logon from the list of previous logons, the default password is the same asthe username. So, if this is your first time running TOAD, your password is yourUsername.

Here, BEQ-LOCAL is the database, the Username is SCOTT and the password entered is TIGER.

Page 10: Toad Users Guide

10

The previous connections list can be sorted by clicking on the Server, User, or LastConnect column header. Click once on a header and the associated list is sortedchronologically or in ascending order. Click twice on a header, and the associated listis sorted in descending order.

The date format comes from the workstation setting in Settings > Control Panel >Regional Settings > Date > Short date style option.

Logon

You can use Oracle usernames without passwords in TOAD. Whatever you enter inDatabase, Username, and Password boxes are passed to the database. If the databasepermits default passwords, then you can connect.

Server Login

You get to this dialog via the File > New Connection menu item, or when TOADstarts up.

You can create a new connection to Oracle or select from a list of previousconnections. TOAD will fill the database dropdown with the names of previoussessions and any aliases in TNSNAMES.ORA.

To create a new connection1 Type the name of the database in the dropdown combo box labeled Database.

The server name you use must have an entry in the TNSNAMES.ORA file.

2 Type the name of the USER in the textbox labeled User/Schema.

3 Type the PASSWORD for the user in the textbox labeled Password. Thecharacters will not display as you type, asterisks will display instead.

4 Click OKORPress <ENTER>.

Page 11: Toad Users Guide

Chapter 2 Logon/Logoff 11

To use a previous connection1 Select a User/ Database combination from the dropdown combo box

ORDouble-click the previous connection from the list in the left panel.TOAD will copy the user name into the Password textbox and will place thecursor in the Password textbox.

2 If the PASSWORD is not the same as the USER, type the PASSWORD.

3 Click OK or press <ENTER>.

4 TOAD saves the USER/DATABASE combinations between TOAD sessionsbut does NOT save the password. There is an option under View > Options,General tab, to Save passwords for Oracle connections and Encrypt savedpasswords. DO NOT ENABLE THESE OPTIONS UNLESS YOU HAVE ASECURE ENVIRONMENT.

To delete a previous connection1 Select a connection from the Server, User, Last Connect list.

2 Press the <DELETE> key.

To run TOAD offline1 Click the <Cancel> button on the Server Login window.

2 Open the offline text editor via the main toolbar button.

Page 12: Toad Users Guide

12

Logon Options

The Login window has five options.

Force SQL*Net (ignore Net8)When checked, TOAD ignores the Net8 DLL’s on your system and attempts toconnect to Oracle via the SQL*Net DLL’s. When the Oracle Home has been found,the DLL with the HIGHEST revision number is loaded. If Force SQL*Net ischosen, Net8 DLL’s are skipped. This also means that a client install with just Net8will result in a failure.

Use SQL*Net Compatible Net8This option only applies to Oracle 8.0.x databases. When checked (ON), you get therow and character position from bad queries, and the cursor is positioned to the pointof error. The downside is that no Oracle 8 functions are supported. When unchecked(OFF), you do not get the error row or column position but you do get the Oracle 8functions. This option does not apply to Oracle 8i because Oracle restored the errorposition function. It assumes that Net8 is installed. The DLL is loaded according tothe above but the new Net8 functions are ignored.

Build Oracle Alias ListThis is the default. When this option is checked, TOAD cycles through yourTNSNAMES.ORA file and the next time you start TOAD it builds connection namesin the Database dropdown list.

Use Last Oracle Home

This will use the Oracle Home that was last installed.

Use the TOAD Home

This will use the Oracle Home selected through the SQL*Net Help dialog.

Page 13: Toad Users Guide

Chapter 2 Logon/Logoff 13

Operating System Authentication

In addition, TOAD can accept logins where the operating system validates the userand password. Select the database alias, and leave the Username and Passwordtextboxes empty. Oracle will prefix your workstation login, and attempt a login. Toconfigure this on the server side, the init.ora initialization parameters file must have:

remote_os_authent = true

os_authent_prefix = "OPS$"

or whatever prefix you select.

For example, Joe Smith logs onto the ORA805 database, enters “ORA805” in theDatabase textbox, and leaves Username and Password empty. His NT login is“JSMITH”, which gets prefixed with “OPS$” giving a username of “OPS$JSMITH.”Oracle attempts a login and TOAD starts up.

The next time you bring up the Server Login window, any previous logins that wereO/S authentication logins will have username = “EXTERNAL”. So, you don’t needto type over the word EXTERNAL in the username textbox when reconnecting.

Page 14: Toad Users Guide

14

SQL*Net Help button

This button displays all Oracle Homes and lets you pick one Oracle Home as yourTOAD Home. It also lets you see which Oracle Homes are valid installs. Theinformation can be copied to the clipboard and pasted into an email for technicalsupport issues.

If a SQL*Net entry is not valid, you can click the Advice button for suggestions.

Page 15: Toad Users Guide

Chapter 2 Logon/Logoff 15

Save Passwords for Oracle Connections

One of the TOAD options is Save Passwords for Oracle Connections. The defaultfor this option is unchecked. This option involves the TOAD.INI file. Normally, onlythe schema and database are saved to the TOAD.INI file for each new Oracleconnection. When unchecked, TOAD puts in the Username for the password. Whenchecked, the password is saved in TOAD.INI.

Before you check the Save passwords for Oracle Connections box, besure you work in a secure environment where your TOAD.INI file will notfall into the wrong hands.

To turn on the option for TOAD Save Passwords for Oracle Connections1 Go to View > Options > Oracle.

2 Click Save Passwords for Oracle Connections to check that option.

3 Either quit TOAD and restartORClick the Save All Options button in the main toolbar.

4 If you do not check the Save Passwords for Oracle Connections checkbox,then the username is copied to the password box because most developmentschemas are created as user/user. So, during login, the password = Username.

Encrypt saved passwords

Next to the Save Passwords option is the Encrypt saved passwords box. Ifchecked, the password is encrypted so that if the TOAD.INI file is pulled into a texteditor, only encrypted text is displayed. So, another user can’t simply see yourpassword by pulling the TOAD.INI file into a text editor.

Page 16: Toad Users Guide

16

To Encrypt saved passwords1 Go to View > Options > Oracle

2 Click Encrypt saved passwords to check that option.

3 Click OK.

If you have previous passwords in the TOAD.INI file and choose to encrypt apassword, then all previous passwords are automatically encrypted. So, you don’thave to go through and encrypt each password individually. The same rule applies tounchecking Encryption. All previous passwords will also have their encryptionfeature removed.

Page 17: Toad Users Guide

Chapter 2 Logon/Logoff 17

Connecting to Personal Oracle

If you are having trouble connecting to Personal Oracle or creating a SQL*Net aliasfor PO7 or PO8, then for the database name on the TOAD login window try one ofthe following four entries:

2:BEQ-LOCALLOCALTCP-LOOPBACK

For Schema/Passwords try one of the following pairs:

DEMO/DEMOSCOTT/TIGERSYS/CHANGE_ON_INSTALLSYSTEM/MANAGER

End Connection

You might want to close a connection without exiting TOAD.

To close a specific connection without exiting TOAD1 Go to the File > End Connection menu.

2 A popup window lists one or more sessions.

3 Click the session you want to end.

4 Click OK.

All windows associated with that session are closed. If you have any Prompt to savebefore close options on, you will be prompted to save the editor contents so that theyare not discarded.

TOAD also has an End All Connections option, accessed from the File menu,which will close all connections.

Page 18: Toad Users Guide
Page 19: Toad Users Guide

Schema Preparation

The following features of TOAD require the creation of database objects: Saved andRecalled Explain Plans, TOAD Features Security, TOAD Source Control, andOracle 8i Profiler Analysis. The scripts to create these tables are in the \TEMPSfolder as follows:

Saved/Recalled Explain Plans TOADPREP.SQL

TOAD Features Security TOADSECURITY.SQL

TOAD Source Control TOADVCS.SQL

Oracle 8i Profiler Analysis TOADPROFILER.SQL

You can create these objects in every schema in which you intend to use them (i.e.,every schema would have these same tables) but the ideal solution would be to createa new user TOAD, create the objects once in the schema TOAD, and grant access tothem to all users via synonyms. These scripts contain the statements foraccomplishing all of this, however, the connection to Oracle used to execute thescript must have the rights to do so.

If you do not want to create a separate TOAD schema or if you want to create therequired tables in several schemas, you can load and execute the script fileNOTOAD.SQL for Saved/Recalled Explain Plans. This script will place all of thenecessary objects for Saved/Recalled Explain Plans in the current schema for thecurrent Oracle session.

NOTE: in View > Options > General tab, you can specify the name of the ExplainPlan table that TOAD should utilize. If you change the default setting fromTOAD_PLAN_TABLE to PLAN_TABLE, TOAD will use your existing table andyou do not have to create the TOAD table. On the other hand, if you still do notexecute the TOAD scripts, you will not be able to recall previous Explain Planresults.

Page 20: Toad Users Guide

20

It is not necessary to execute TOADPREP.SQL in order to use TOAD. If you do notexecute the script, TOAD will not display previous Explain Plan results.

Explain Plan will still function on the SQL Edit window providing you specifyPLAN_TABLE on the options window rather than TOAD_PLAN_TABLE. If youdecide NOT to store previous Explain Plan results, you should disable the optionSave previous Plan results on the Options window.

TOAD uses the Windows User name plus the date and time to generate a uniquestatement id for the Explain Plan. If the user has a longer than normal user name, youmight need to expand the Statement_ID column of the Plan table.

Page 21: Toad Users Guide

Basic Navigation

This section contains basic information about TOAD buttons, Hot Keys, Right-ClickMenus, etc. If you are unfamiliar with windows navigation/operation, or you havecome across a button you don’t understand, this section should help.

MouseTOAD is designed to be used with a mouse. In addition to pointing and clicking onitems, the right-click button displays Right-Click Menus that are associated withdifferent areas of TOAD. Right-Click Menus are discussed in the Right-Click Menusection of this chapter (page 30).

Expand/Collapse buttons

Some sections will have a list of categories with expand buttons next to eachcategory item. Click the expand symbol to expand the list. This is similar to double-clicking a file folder in Explorer to open its contents. If the category is alreadyexpanded, you can click the collapse symbol to collapse the list.

Drill Down buttons

The expand symbol The collapse symbol

The drill down button

Page 22: Toad Users Guide

22

Drill down buttons indicate another level of information. Click the drill down buttonto “drill down” another layer, which is usually another window.

Radio buttons

Radio buttons let you select one choice. You cannot select more than one radiobutton from a radio button list at the same time. To select a radio button click in thebutton area (or on the corresponding text to the right of the button) and a black dotwill display in the selected button.

Clicking on the drill down button on this window will display a fonts window.

Page 23: Toad Users Guide

Chapter 4 Basic Navigation 23

Checkboxes

You will find checkboxes throughout TOAD. The program is designed to be flexible,and with checkboxes you control how TOAD looks and functions. Unlike the radiobuttons, you can check multiple items in a checkbox list. Remember, options you’veset in one checkbox might affect options in another checkbox.

To place a check in a checkbox or remove a check from a checkbox

Click in the checkbox areaORTab to the area with the checkboxes and press the up and down arrow keys until youroption is highlighted. Press the space bar.

To check/uncheck items in the Right-Click MenusClick the item.

Here, the main toolbar Right-Click Menu displaysa Show Main Toolbar option which can bechecked/unchecked by clicking the menu text.

Page 24: Toad Users Guide

24

Dropdown lists

test

Dropdown lists are used throughout the TOAD screens. The down arrow activates adropdown list from which you can choose an item. To access the dropdown list, clickthe down arrow.

Textboxes

For textboxes, click in the textbox area and then type in the text or numeric entry.

Page 25: Toad Users Guide

Chapter 4 Basic Navigation 25

Types of Message Boxes

TOAD uses the industry standard symbols for its four types of message boxes.

i This indicates an information box.

? This indicates a question box that requires a decision from you.

X This indicates a stop message.

! This indicates an exclamation (very important) message.

This is an example of an exclamationmessage box.

This is an example of an information box. This is an example of a question box.

This is an example of a stop message box.

Page 26: Toad Users Guide

26

Keyboard

You can use the keyboard for navigation and selection for part of the TOAD menus.

TAB

The TAB key lets you advance the cursor forward from one area of a window toanother area. The first item in the area you tab to will highlight.

For textboxes, you can TAB to the textbox and the text cursor displays ready for youto type.

UP/DOWN ARROWS

The UP ARROW and DOWN ARROW let you move your cursor up and down theitems or list of whatever area your cursor is positioned in. In a dropdown list the UPand DOWN ARROWS scroll through the choices in the list. The UP and DOWNARROWS are referred to as the UP and DOWN keys.

LEFT/RIGHT ARROWS

The LEFT ARROW and RIGHT ARROW let you move left and right across a list ofradio button choices. Once you reach your choice, TAB to move out of the area (orclick outside of the area with your mouse) and your choice remains. You can alsouse the UP/DOWN arrow keys to move through the radio button choices.

For the Expand and Collapse buttons the LEFT ARROW collapses the list and theRIGHT ARROW expands the list.

You can also expand and collapse buttons using the numeric keypad using the <+>and <-> buttons. The plus sign “+” expands the list and the minus sign “-” collapsesthe list. For hierarchy lists, the multiplication sign “*” expands to all levels.

SPACEBAR

The spacebar lets you check and uncheck checkboxes or click buttons with focus.

Page 27: Toad Users Guide

Chapter 4 Basic Navigation 27

ENTER

ENTER is similar to a mouse-click. It activates whatever button has focus. Forexample, if you <TAB> to a CANCEL button and press <ENTER>, you will cancelyour choices and exit the window. Pressing <SPACEBAR> on buttons with focusalso clicks the buttons.

ESC

ESC cancels most modal dialogs.

Not Accessible by Keyboard

TOAD was designed for a mouse, and some areas of TOAD can only be accessed byusing the mouse.

For example, drill down buttons cannot be tabbed to. You have to click the drilldown button to bring up its associated window.

A drill down button can only be activated by a mouse-click.

Page 28: Toad Users Guide

28

Hotkeys – adding/altering

The Editor Options Dialog list of key assignments contains a list of the basic editingfunctions.

<CTRL><INSERT>, <SHIFT><INSERT>, and <SHIFT><DELETE> aremapped to copy (<CTRL>C), paste (<CTRL>V), and cut (<CTRL>X)automatically.

When you highlight a command, you can alter the key assigned to that command ORadd an additional key. All commands allow for two-part keystrokes; for example, theold WordStar commands such as Control-K, 0 for the command "set Bookmark 0."

To set the command for "Bookmark0" to "Control-K, 0"1 Click the Edit > Editor Options > Key Assignment item.

2 Expand the Bookmarks list by clicking the expand “+” button.

3 Click Set Bookmark 0.

4 Click the Edit Sequence button.

5 The Edit Key Pair step window displays.

6 Press <CTRL>K. The key sequence displays in the window.

7 Click Next.

8 The optional Step 2 window displays.

9 Press 0.

10 Your second key, 0, displays in the window.

11 Click Finish.

12 The setting is saved.

If Key2 shows anything other than <none>, that command expects a secondkeystroke.

To remove the second keystroke1 Click in the textbox labeled Key2.

2 Press <ESC> to clear the keystroke, <none> will display.

Page 29: Toad Users Guide

Chapter 4 Basic Navigation 29

3 The setting is saved.

Note that key strokes such as <CTRL>J or <SHIFT><INSERT> are ONE strokekeys.

DO NOT CLICK the buttons ADD or DELETE unless the keys you just enteredshould be in addition to the default keystrokes OR you want to remove the displayedkeystrokes entirely. If you click DELETE while looking at a command, the hotkeyfor that command is removed.

To change a one-stroke key1 Select the command from the list.

2 Press the Edit button.

3 Click in the textbox labeled Key1.

4 Press <CTRL>J (or the desired keystroke).

5 Click in the textbox labeled Key2.

6 Press <SHIFT> to clear any existing key stroke.

7 Click Finish.

8 The setting is saved.

Both <SHIFT> and <ESC> can clear an existing keystroke.

This options tab is also useful for documenting the default keystrokes andkey-activated functions.

Right-Click Menu button OR F10 Key – access menus

Schema BrowserSQL EditorProcedure Editor

See the Right-Click Menu topic (page 30) for more information.

Page 30: Toad Users Guide

30

Right-Click MenusThis section gives an overview of the Right-Click Menus. The items in differentRight-Click Menus are discussed in detail in the applicable sections of this guide.For example, the Debugger Right-Click Menu is discussed in detail in the Debuggerchapter.

A Right-Click Menu is specific to the window that you are in. Some items in themenu are shortcuts to commands or windows that can be found elsewhere, and someitems are unique to the Right-Click Menu and cannot be found anywhere else inTOAD.

To access the Right-Click MenuPress the right mouse button (right-click)ORFor the Procedure Edit and SQL Edit windows, Press F10.

Right-click in the SQL Editor Results Gridand this Right-Click Menu displays.

Page 31: Toad Users Guide

Chapter 4 Basic Navigation 31

Location of Right-Click Menus

SQL Editor

Editor

The edit window (or editor) Right-Click Menu includes the following functions:Paste, Set Bookmark, Goto Bookmark, Describe, Search Knowledge Base, UpperCase, Lower Case, Format SQL (uses PL/Formatter from RevealNet if installed,otherwise, uses basic formatting), Comment Block, Uncomment Block, FindClosing Block, Blank DBMS Output Statement, Make DBMS Output Statement,Save, Load, Show Editor Toolbar, Editing Options, Unix Style Save, Autotrace,SQL Trace (tkprof), and Optimizer Mode.

SQL Results Grid

The data grid, or SQL results grid, Right-Click Menu includes the followingfunctions: Memo Editor, Print Grid, Save As, Select Columns, Export to Flat File,Find Data, Copy Row, Record Count, Number of Fixed/Anchored Columns, RowHeight, Allow Multi-Select, Grid Font, Sizing Column widths to Data, RowNumbers, and Row Highlight.

Procedure Editor

Editor

The Procedure Editor Right-Click Menu includes the following functions: Paste,Upper Case, Lower Case, Set Bookmark, Goto Bookmark, Debug, Describe,Search Knowledge Base, Compile, Save to File, Load from File, Check in Source,Unix Style Save, Load Procedure, Show Navigator List, Comment Block,Uncomment Block, Format Statement (requires PL/Formatter from RevealNet),Blank DBMS Output Statement, Make DBMS Output Statement, Find ClosingBlock, Show Edit Toolbar, and Editing Options.

Page 32: Toad Users Guide

32

Schema Browser

Object Lists

The Right-Click Menu over the label tabs on any of the main lists on the left handside of the window displays a menu to show/hide the main panels. For example, tohide the Synonyms list if you do not require access to Synonyms. You cannot hidethe Tables tab.

Tables Tab

Create Script, Export Data, Privileges, Truncate, Analyze, Add Column, AddIndex, Add Constraint, Show Column Comments in List

Procs Tab

Save to File, Compile, Compile Dependencies, Load in Procedure Editor, ExecuteProcedure, Privileges, Copy Source to Clipboard, Copy Selected Source toClipboard, and Print Source

Views Tab

Compile, Format SQL, Copy to Clipboard, Load Source in SQL Editor, and ShowColumn Comments in List

Data Grids

The Data grids for Tables and Views also has a Right-Click Menu for thefollowing functions: Memo Editor, Print Grid, Posting Changes/Edits, SelectingColumns, Saving to File/Clipboard, Row Height, Number of Fixed/AnchoredColumns, Copy Row, Record Count, Allowing Multi-Select, Displaying RowNumbers, and Row Highlight.

Page 33: Toad Users Guide

Chapter 4 Basic Navigation 33

The Main Toolbar Right-Click Menu

Right-Click on the main TOAD toolbar to display a right-click menu that lists adisplay option and a save command.

Show Main Toolbar

The default is checked. When this option is checked the main toolbar will display.When this option is unchecked, the main toolbar is not displayed.

Save TOAD Options

Saves external files which are basically your current TOAD settings and values.

This is useful if you are about to run a query that could crash or run for a long time.You might want to Save TOAD Options before running that query, just as aprecaution. It saves all TOAD options to files in your TOAD and TOAD\TEMPSfolders including settings from the TOAD Options dialog, Editor Options settings,Recall Previous SQL lists, Lists of MRU (Most Recently Used) files, Table Namealias list, etc.

NOTE:The Save TOAD Options button from the main toolbar does exactly the same thingas the Save TOAD Options command that is in the main toolbar Right-Click Menu.

The Right-Click Menu for the main toolbar

T

he Save TOAD options button
Page 34: Toad Users Guide
Page 35: Toad Users Guide

Main TOAD Window Toolbar

When you first run TOAD the Main TOAD Window displays.

The Toolbar on the Main TOAD window

Open a new SQL Edit window with the current active connection

Open a new Schema Browser window with the current active connection

Open a new Procedure Edit window with the current active connection

Open a new SQL Modeler window with the current active connection

Open a new Explain Plan window with the current active connection

Open a new DBMS_OUTPUT window with the current active connection

Open a new Object Search window with the current active connection

Save all options normally saved when exiting TOAD

Open a modal TOAD Reports dialog with the current active connection

Open a new Offline Text Editor window (no Oracle connection required)

Toggle PL/SQL Profiling ON or OFF

Show Windows by Connection, minimizes non-selected MDI child windows,restores MDI child windows for the selected Oracle connection

Open a new Oracle Connection to the database

Page 36: Toad Users Guide

36

To hide the TOAD main toolbar1 Right-click over the toolbar.

2 Uncheck the Show Main Toolbar menu item.

To show the TOAD main toolbar1 Right-click over the TOAD MDI parent window client area (minimize or

rearrange the other MDI child windows).

2 Check the menu item, Show Main Toolbar.

Page 37: Toad Users Guide

SQL Editor

This section introduces the SQL Edit window. If you have never used TOAD, theSQL Edit window is a good starting point. The window contains an editor tocompose SQL statements or scripts and a results grid to display the results fromSELECT SQL statements. At the end of the chapter step-by-step examples areprovided for various SQL Edit procedures.

The SQL Editor lets you type, edit, execute, and tune. When you first start TOADyou are in a SQL Edit window. The SQL Edit window has two panels. The SQLEditor is the top panel and the Results Grid, the lower panel, displays fetched data. Ahorizontal splitter between the editor and results grid lets you size each componentaccordingly.

3 ways to invoke the SQL Edit window

� Click the first button in TOAD’s main toolbar.

� Select menu item Database > SQL Editor.

� Set the SQL Editor to StartUp on new connection in the View > Options >Startup dialog.

The SQL Edit window has two toolbars. The top toolbar is for SQL Edit specificfunctions. The bottom toolbar, or edit toolbar, is for common editing functions suchas copy, cut, and paste. The edit toolbar is also on the Stored Procedure Edit window.

To hide/show the Edit Toolbar1 Right-click over the Editor.

2 Click to Check/Uncheck the Show Edit Toolbar menu item.

Page 38: Toad Users Guide

38

Toolbar buttons

Execute the complete or highlighted statement

Execute the statement at the cursor

Execute all of the current window as a script

Recall Previous SQL statement

Recall Personal SQL statement

Insert a row into an editable SQL Results Grid

Delete the current row of data from the SQL Results Grid

Update SQL Results Grid edits to the database (not a commit!)

Reverse changes to the current query not yet posted

Perform an Oracle Commit, which affects all open windows for the current session

Load a file into the SQL editor

Specify a file to save the current editor contents

Save to File

Take the current SQL statement and create a development tool code statement

Take a development tool code statement and Strip out the Oracle SQL statement

Execute Explain Plan for the current statement

The SQL Edit Specific toolbars

Page 39: Toad Users Guide

Chapter 6 SQL Editor 39

Display/Close the embedded DBMS_OUTPUT window

Tune the selected SQL statement with the SQLab Xpert/Tuner module

Change active session for this window

Page 40: Toad Users Guide

40

Shortcut Keys

F1You can press F1 while in the SQL Edit window to display a help file that lists theshortcut keys.

A few keys to note

F4Describes an item (table, view, procedure, function, or package) in a popup window

F6Toggles the cursor between the SQL Editor and the Results Grid

F10Displays the Right-Click Menu for the section (Editor or Results Grid) that thecursor is in

<CTRL>TColumns Dropdown – You put the cursor on the table name and a popup windowlists the columns in that table.

<ALT><UP>Goes to the previously executed statement that you’ve run

<ALT><DOWN>Goes to the most recently executed statement

<HOME>Goes to the beginning of the line

<CTRL><HOME>Goes to the top of the editor, in the results grid, goes to the first row of the columnthe cursor is in

<END>Goes to the end of the line

<CTRL><END>Goes to the last row of the column you are in (See CAUTION note)

Page 41: Toad Users Guide

Chapter 6 SQL Editor 41

CAUTION: You need to be careful when using <CTRL><END>. TOAD showsqueries quickly. Even in a table with a million rows the response is almostimmediate. This is because TOAD only fetches and displays what it needs. But, with<CTRL><END> TOAD has to fetch EVERYTHING. This can be a long process.So, if a table has only a hundred rows TOAD can quickly fetch data when you press<CTRL><END>, but if a table has a million rows, the process could be timeconsuming.

If you need to examine rows at the end of a large recordset, refine your query withsomething like:

Select * from table

Where primary_key > value

And re-execute it.

Page 42: Toad Users Guide

42

KEYSTROKE FUNCTION

F1 Display SQL Editor section of TOAD Help file

F2 Toggle between full screen Editor and Editor/Results Grid display

F3 Find next occurrence

<SHIFT>F3 Find previous occurrence

F4 Describe Table, View, Procedure, Function, or Package in popup window

F6 Toggle cursor between Editor and Results Grid

F7 Clear all text

F8 Recall previous SQL statement

F9 Execute statement

<CTRL>F9 Verify statement without execution (parse)

<SHIFT>F9 Execute current statement at cursor

F10 Display Right-Click Menu

F12 Pass the editor contents to the specified External Editor

<CTRL>A Select all text

<CTRL>C Copy

<CTRL>D Show Procedure Arguments

<CTRL>E Execute Explain Plan on the current statement

<CTRL>F Find text

<CTRL>G Goto line

<CTRL>L Convert text to lowercase

<CTRL>M Make Code Statement

<CTRL>N Recall Named SQL Statement

<CTRL>O Open a text file

<CTRL>P Strip Code Statement

<CTRL>R Find and Replace

Page 43: Toad Users Guide

Chapter 6 SQL Editor 43

<CTRL>S Save File

<SHIFT><CTRL>S Save File As

<CTRL>T Display Columns dropdown

<CTRL>U Convert text to uppercase

<CTRL>V Paste

<CTRL>X Cut

<SHIFT><CTRL>Z Redo last Undo

<ALT><UP> Display Previous Statement

<ALT><DOWN> Display Next Statement (for use after <ALT><UP>)

<CTRL><HOME> In the data grids, go to the top of the recordsetIn the results grid, go to the first row of the column the cursor is inIn the editors, go to the first row, first column of text.

<CTRL><END> In the Data Grid, go to the end of the recordsetIn the editors, go to the last row, last column of text.See CAUTION NOTE in this section.

<CTRL><SPACE> Activate code completion template

<CTRL><TAB> Cycle through the collection of MDI Child windows

<CTRL><ENTER> Execute current SQL statement at cursor

<CTRL>. (period) Auto complete tablenames

Page 44: Toad Users Guide

44

Using the SQL Editor

Selecting a table to editTo edit a table, you can’t simply type Select and the tablename. Nothing will happen.You have to include a rowid in your select statement.

For example, if your tablename is DEPT and you type

Select dept.rowid, dept.* from dept

And press <CTRL><ENTER> or F9 to execute, you can edit the data.

Alternatively, you can type the TOAD EDIT command to translate the commandinto a SELECT SQL statement with ROWID column.

Edit dept

and press <CTRL><ENTER> or F9 to execute. Then you can edit the data.

Table Names Select

If you want to choose a table, and can’t remember the title or schema, click the ShowTables window button and the Table Names Select window displays from which youcan choose the owner and the table. You can even click on a table name and drag anddrop that name to the SQL Edit window.

Show Tables window button

Page 45: Toad Users Guide

Chapter 6 SQL Editor 45

Then type Edit before the name, add a space

Example: edit dept

Go to the end of the command line

and press <CTRL><ENTER>.

Your selected table displays in the Results Grid.

Notice the status panel indicator at the bottom of the screen turns green. Thisindicates that the table data can be edited. When the indicator is red, that indicatesthat the data is not editable. That means the data cannot be edited, but it can still beselected and copied.

Status Panel Indicator: green=editable red=not editable

Page 46: Toad Users Guide

46

Single Record View

Also notice the Single Record View button. This button is present throughoutTOAD data windows and result grids. It is located on the top left of the table.

Click the Single Record View button and the Single Record View window displaysfor the record of the item you’ve selected. The arrow buttons in the window let youmove up and down the columns. You can also insert records, delete records, and postedits.

Single record view button

H3C

First record

Prior record

Next record

Last record

Insert recor

Delete reco

Post edit

Cancel edit

Refresh da

ere, the location for Department0, Sales, was changed fromhicago to New York.

d

rd

ta

Page 47: Toad Users Guide

Chapter 6 SQL Editor 47

Commit

The ComWhen ydata untcancels

You canCommisession.

Commityou the Commit

To TurGo to V

Check o

Notice aif autocuncheckTOAD before y

C

ommit

mit command executes an Oracle Commit, sending data to the database.ou edit a cell in a table, a transaction occurs. Other users can only see the oldil you commit. Commit writes the transaction to the database. Rollbackthat transaction.

choose Commit from the Database > Commit menu item or click thet button. This performs a commit for all windows that are open in the current

can be ON or OFF. The status panel on the bottom of the window showsstatus of Commit. Data is not available to other users until you choose. So, with Commit OFF you can make changes without affecting other users.

n Commit ON or OFFiew > Options > Oracle.

r Uncheck the Commit automatically after every statement item.

related option on the next line is Prompt for Commit when closing TOADommit is disabled. If the Commit automatically after every statement ised, and the Prompt for Commit when closing TOAD option is checked,

will ask you whether or not you want to perform a commit to the changesou close a session.

The status panel shows the status of Commit

Page 48: Toad Users Guide

48

As soon as you start editing a table, the Update Grid Edits button is enabled. TheUpdate Grid Edits command sends the latest edits (or data) to the database. Ifautocommit is ON at the time the Update Grid Edits is activated, the data will becommitted. If autocommit is OFF, the data is buffered in the transaction.

When you edit data in a row, the changes are not sent to the Oracle transaction bufferuntil you change rows (click in another row). However, if you only have one row,you can’t change rows. That’s where the Update Grid Edits command is useful. Youcan edit in the row and then, without changing rows, click the Update Grid Editbutton, and the data is sent to the Oracle transaction buffer. If autocommit is OFF, itstays in the buffer. If autocommit is ON, then the data is committed.

So, if Commit is ON and you type in a row and then change rows, the data isavailable to other users. With Commit OFF, you can make changes, but other userswill see the old data, until you choose Commit.

Next to the Update Grid Edits button is the Reverse Changes button. This lets youreverse the changes you’ve made that have not yet been posted. For example, typingin col 1, pressing <TAB>, typing in col 2, pressing <TAB>, then clicking theReverse Changes button will reset col 1 and col 2 to their previous values.

Update Grid Edits

Reverse Changes

Page 49: Toad Users Guide

Chapter 6 SQL Editor 49

Explain PlanExplain Plan (also called Execution Plan) displays steps that will occur in theselected SQL statement. This lets you visually see the steps. The purpose of ExplainPlan is to determine the execution plan Oracle follows to execute a specified SQLstatement. The Explain Plan function inserts a row describing each step of theexecution plan into a specified plan table. If you are using cost-based optimization,Explain Plan also determines the cost of executing the statement.

NOTE:

Viewing previous Explain Plans via View > Explain Plan will not work unless youfirst run the TOADPREP.SQL script which is explained in this section. <CTRL> EExplain Plans in the SQL Editor will work regardless of TOADPREP.SQL, but ifyou have not run TOADPREP.SQL you must to set the View > Options > Oracle >Explain Plan Table name option to point to your own plan table (Plan_Table).

To execute Explain Plan on a SQL StatementIn the SQL Editor, place the cursor on a SQL statement, go to SQL Window >Explain Plan Current SQL (OR <CTRL>E)

If View > Options > Oracle > Save previous Explain Plan results is checked on,then Explain Plans are stored in:TOAD_PLAN_SQL andTOAD_PLAN_TABLE

TEMPS – TOADPREP.SQL

The Explain Plan window will not display previous Explain Plans unless you runTOADPREP.SQL which creates the temp tables needed for storage and retrieval ofExplain Plans. TOADPREP requires you to step through and execute each statementin the script. This is explained in the README file. You must have System or DBAaccess in order to run the TOADPREP.SQL script.Excerpt from the README file:

For the TOAD temp tables, run TEMPS\TOADPREP.SQL to create a separate

TOAD schema. Or if you do not want a separate schema for the TOAD temp

tables, run TEMPS\NOTOAD.SQL.

Page 50: Toad Users Guide

50

To Load and Execute TOADPREP.SQL

1 Connect to the SYS or SYSTEM schema, or a schema with the DBA role.2 Go to File > Open File.3 Open your TOAD > TEMPS folder.4 Double-click on TOADPREP.SQL.5 This loads TOADPREP.SQL into your SQL Editor.6 Execute each statement in the script by clicking on the statement and pressing

<CTRL><ENTER>.

NOTE: If this is your first time running the TOADPREP.SQL script and youexecute a Drop statement, you receive an error message. This is because there isnothing to drop. You can click OK and continue. However, you can just skip allthe drop statements (don’t execute the drop statements), since TOAD hasnothing to drop.

7 For the Connect statement, you need to modify the statement for yourconnection.

8 When you exit, TOAD will ask you if you want to save changes. Click Yes.

So, the first time you run TOAD you need to execute TOADPREP so it can createthe two tables of information that Explain Plan needs (TOAD_PLAN_SQL andTOAD_PLAN_TABLE).

To run Explain Plan

1 Load a SQL Script into the SQL Editor.2 Click on a SQL statement such as Select, Insert, Update, or Delete.3 Select SQL-Window > Explain Plan Current SQL menu item.4 Explain Plan results display in the results grid.

This is an example of Explain Plan results for a selected statement.

Page 51: Toad Users Guide

Chapter 6 SQL Editor 51

Notice the Explain Plan results have expand and collapse buttons. They let youdisplay the details that you need to see.If you attempt to activate an Explain Plan and you have not created the neededTOAD temp tables, you get an error message telling you the table or view does notexist.

You can copy the Explain Plan hierarchy to the Windows clipboard or send it to theprinter with a right mouse-click over the Explain Plan output and selecting either theCopy to Clipboard or Print Results menu item

View Explain Plan

View Explain Plan displays a list of the previous Explain Plans that you’ve executed.

To Access View Explain Plan1 Go to the View > Explain Plan menu item.

2 Click the Explain Plan item.

3 A list of previous Explain Plans displays.

NOTE: You must have the View > Options > Oracle > Explain Plan TableName menu item entered or you will not be able to view previous plans. The defaultentry is TOAD_PLAN_TABLE.

Refer to Oracle documentation for how to read and interpret an Explain Plan output.

Page 52: Toad Users Guide

52

Offline Text Editor

TOAD has an Offline Text Editor window. So, you can edit scripts without beingconnected to an Oracle database.

For example, by modifying the script files that define how the TOAD Editor shouldhighlight keywords, you could edit HTML files, and have TOAD highlight theHTML markup tags in various colors.

The file language types supported are:

� PL/SQL� HTML� INI� JAVA� TEXT

The file associations for file name extension and language type is set up in theTOAD > Options > Files dialog.

Each language type supports separate lists of:

� Editor Options� Key Assignments� Editor Parser Scripts� Auto Substitutions

Opens a new Offline Text Editor window (no Oracle connection required)

Page 53: Toad Users Guide

Chapter 6 SQL Editor 53

The Options > Files dialog

Page 54: Toad Users Guide

54

Here, the different HTML tags are highlighted in different colors.

Page 55: Toad Users Guide

Chapter 6 SQL Editor 55

Recall and Add SQL

The purpose of Add/Recall SQL is to create a list of previously executed SQLstatements in order to recall them at a later date, instead of having to retype them.

There are three different types of Add/Recall SQL statements:

� Recall Previously Executed

� Recall Personal SQL

� Recall Named SQL

The recall and add SQL dialogs can be accessed through the SQL-Window menu.

SQL Recall Window

The SQL Recall window has buttons that let you move to the Next or Previousstatement. It also has buttons to Append, which means add the statement to yourcurrent SQL script, or Replace which would replace your current script withwhatever SQL statement you select. You can copy statements to the clipboard byclicking the Clipboard button. The Remove button lets you remove selectedstatements from your list. Cancel closes the window and returns you to the Editor.

There are also tabs to display All SQLs and Single SQL which show more detail ofa long SQL statement. On the All SQLs tab, the grid row height is verticallyadjustable on a row by row basis. Move the mouse over the record selector and dragup or down.

You can even search by clicking in the SQL Contains textbox, typing the text youwant to search for, and clicking GO. The list will scroll and highlight the statementthat contains your search item.

Page 56: Toad Users Guide

56

To Recall a SQL command

Click the Recall Previous SQL button in the SQL Edit window toolbarORPress F8ORSelect SQL Command Recall from the SQL – Window.

The SQL Statement Recall window displays. It includes options for searching inSQL statements, deleting SQL statements, and displaying all or selected SQLstatements.

The Recall window displays a list of the last X number of statements executed. Thedefault number is 100, but you can change this in the options. See the Options for theSQL Editor topic on page 60 for more details. The list of SQL statements is writtento and read from the SQLS.DAT file from the TOAD folder.

Running a Recalled SQL Statement

After a SQL statement is recalled and placed in the SQL Editor, press<CTRL><ENTER>, or <SHIFT>F9. TOAD will search backwards one line fromthe current cursor position to find a SQL statement to execute.

Add to Personal SQLs

Selecting this command from the SQL-Window menu adds the SQL statement that’sin the SQL Editor to your personal SQLs. You can later recall the statement by usingthe Recall Personal SQL command.

TOAD saves all statements in this list between sessions of TOAD, in a file namedPERSSQLS.DAT in the TOAD folder.

To Add a SQL Statement to the Personal SQL List1 Select the statement by highlighting it in the editor.

2 Click menu item SQL –Window > Add to Personal SQLs.

SQL Command Recall or Recall Previous SQL

Page 57: Toad Users Guide

Chapter 6 SQL Editor 57

You access the window by clicking the Recall Personal SQL button in the SQL Edittoolbar or via the SQL-Window > Recall Personal SQL menu item.

You have to add a Personal SQL Statement before you can Recall a Personal SQLStatement. Recall Personal SQL only lists the ones that you’ve added to the list.

This window functions identically to SQL Statement Recall except that the list andorder of statements is controlled by the TOAD user.

Add to Named SQLs

This window lets you add a SQL statement to a user’s named favorite list.

To Add a SQL Statement to the Named SQL List1 Select the statement by highlighting it in the editor.

2 Click menu item SQL – Window > Add to Named SQLs.

3 Type the name you want to assign.

4 Click OK.

Recall Named SQL

You get to this dialog via the SQL Window > Recall Named SQL menu item (orpress <CTRL>N).

The SQL Statement Recall window for Recall Named SQL

Recall Personal SQL

Page 58: Toad Users Guide

58

Use this dialog to pick a SQL statement from your named list of SQLs, then copy itback to the SQL Edit window for execution. The Recall SQL window for RecallNamed SQL lists the names on the left panel and highlights the corresponding SQLstatement on the right panel.

The SQL statements are stored in the NAMEDSQL.DAT file in the TOAD\TEMPSfolder.

This window is a combination of SQL Command Recall, Recall Personal SQLs, andRecall Named SQL.

More about Recall

Every statement executed in a SQL Edit window is added to a most-recent-first list.You can select/recall a statement from this list on the Statement Recall window.You can also remove statements from this list.

All statements (to a maximum set in User Options) are saved between sessions ofTOAD, in the file SQLS.DAT in the TOAD folder.

You can scroll through the previous statements directly within a SQL Editor editpanel by pressing <ALT> <UP> or <ALT> <DOWN>.

You can check the Save Only Statements that are Valid checkbox in the TOADOptions dialog, SQL Edit tab. This checkbox item will only save those SQLstatements that executed successfully. This prevents the list from containingmisspelled column names, SQL clauses, etc.

Append versus Replace

There is an option on the View > Options > SQL Editor tab > SQL windowbutton on SQL Recall window Appends rather then replace. This changes thedefault button to be set to Append rather than Replace for the SQL Recall window.So, when you press F8 to recall a statement (or recall a statement via a menu item), ifAppend rather than Replace was checked, the Append button will be the defaultbutton, but you can still select the Replace button. If you double-click in the grid itactivates the default button. If you select a statement in the grid and press <ENTER>it also activates the default button.

Page 59: Toad Users Guide

Chapter 6 SQL Editor 59

Bind Variables

You can execute SQL statements in the SQL Editor using bind variables, where acolon leads the bind variable name, e.g.,

Select * from employee where last_name = :NAME

And TOAD will present the Variables popup window for you to input the value forthe NAME bind variable. These values you enter are stored and retrieved forsubsequent queries in the PARAMS.TXT file in the TOAD\TEMPS folder.

Substitution Variables

You can also execute SQL statements with substitution variables, where theampersand leads the substitution variable name, e.g.,

SELECT * FROM &schema.EMPLOYEE

And TOAD will present the same Variables popup window for you to enter the valuefor &schema. If you want to query DEMO.EMPLOYEE, enter DEMO. If youwanted to query SCOTT.EMPLOYEE, enter SCOTT.

Page 60: Toad Users Guide

60

Options for the SQL Editor

The View > Options > SQL Editor tab provides numerous options.

NOTE: Options for the SQL Editor are spread across three dialogs: TOAD Options> SQL Editor, TOAD Options > Editors, and Edit > Editor Options. See page 78for more information on the Edit > Editor Options menu.

Page 61: Toad Users Guide

Chapter 6 SQL Editor 61

Process Statements in Threads/Allow Queries to be Cancelled

Default – Unchecked

If checked, TOAD will issue each query in a separate thread. The Cancel button willdisplay on the SQL Edit window toolbar to the right of the Change Active Sessionbutton, enabling you to cancel a long running query before any data is returned. Thedisadvantage to having this option checked is that more processing must occur, sodata retrieval is slower.

Save Only Statements that are Valid

Default – Unchecked

If this option is checked, TOAD will only save the SQL statements that ransuccessfully, for recall via F8 SQL Statement Recall dialog.

# of SQL Statements To Save textbox

The default number is 100.

This box lets you enter a custom number of SQL statements to save to your RecallPrevious SQL list. The list is saved to and retrieved from the SQLS.DAT file. Onlythe most recently used SQL statements are saved.

Save SQL Statement Before Statement Execution

Default – Unchecked

If checked, TOAD saves the SQL statement before executing it, in case somethinghappens during the execution.

If this option is checked, the Save only statements that are valid option will notapply.

Show Columns Rather Than View Text Following a DESCRIBE Viewname

Default – Checked

If checked, TOAD will show the columns of the view, in the SQL Edit results grid.If unchecked, TOAD will fetch and show the view text in the SQL Edit window.

Page 62: Toad Users Guide

62

Process Update, Insert, and Delete Statements in Background

Default – Unchecked

If this option is checked, UPDATE, INSERT, and DELETE statements will beprocessed in the background. When executed, the statements are actually copied to aseparate status window to provide a visual indication that the statement is running.Processing lengthy statements in the background frees up TOAD as well as yourmachine for other tasks.

Show Editor Toolbars on SQL Editor and Procedure Editor

Default - Checked

The SQL Editor and Procedure Editor have two rows of buttons (two toolbars).Displaying the second row of buttons, known as the editor toolbar, is optional andcan be controlled via this option. If this option is checked, the editor toolbars willdisplay. Note: the editor toolbar can also be displayed or hidden via the Right-ClickMenu of the editors.

Allow F7 to Clear All Text

Default – Checked

If checked, you can press the F7 key to clear all text from the SQL Edit window,without a confirmation dialog. If unchecked, F7 will not work, but you can still usethe Edit > Clear All menu item.

Note: Text deleted via F7 is not reversible by Edit > Undo.

Prompt to save contents when closing editor

Default – Unchecked

If checked, TOAD will prompt you to save any text you typed in the editor.

Make Code Format dropdown list

Default - VB

Page 63: Toad Users Guide

Chapter 6 SQL Editor 63

This dropdown list lets you select the language syntax for TOAD to convert a SQLstatement into (Make Code Statement function) and out of (Strip Code Statementfunction). Currently, Delphi, VB, C++, Java, and Perl are supported.

Scan Statements for Bound Variables Before Execution

Default – Checked

If checked, TOAD will scan SQL statements for bound variables and ask you for thevalues before execution. If unchecked, TOAD will tell you that the variables are notbound.

Allow RTF when copying to/from clipboard

Default – Checked

If checked, TOAD will copy color markups, for pasting into email or other RTFenabled applications. If unchecked, the text will be copied to the clipboard asstandard black text.

SQL Window button on SQL Recall Window appends rather than replaces

Default – Unchecked

If checked, the default button and behavior will append the selected SQL to thecurrent contents of the SQL Edit window. If unchecked, the default button andbehavior will REPLACE the current contents of the SQL Edit window.

Always Show Statement Execution Time (overrides ROW:COL Display)

Default – Unchecked

If checked, TOAD will show the statement execution time in the status panel. Ifunchecked, TOAD will show the statement execution time until you perform furtherediting, then the status panel will show the row and col location of the cursor in theeditor.

Use popup windows when executing DESC statements

Default – Checked

Page 64: Toad Users Guide

64

If checked TOAD will present you with a popup window of complete object detailwhen executing a "DESC object_name" statement. If you prefer the results to bepresented in the SQL Results grid, then uncheck this option. Regardless of thisoption setting, selecting an object and pressing F4 will use the popup windows.

Use StayOnTop Popups

Default – Checked

If checked, the F4 popup Object Describe windows will use the windows Stay onTop feature.

Only show one SQL Editor per database connection

Default – Unchecked

If checked, TOAD will permit only one SQL Editor window to be opened perconnection. This is similar to the one Schema Browser or one Procedure Editor perconnection options.

Page 65: Toad Users Guide

Chapter 6 SQL Editor 65

Executing Statements

If the SQL Edit window has a single statement that you wish to executePress F9ORClick the Execute Statement button on the toolbar.

If you only want to process a portion of the edit textHighlight that portion and :

1 Press F9

OR

2 Click the Execute Statement button.

To execute a single statement among many statements (separated by atleast one blank line)Click or place the caret/cursor within the statement you want to executeANDPress <SHIFT> F9 OR <CTRL><ENTER>

OR

Click the Run Current Statement button on the toolbar.

TOAD supports query statements, DDL statements, blocks of procedure SQL, etc.

Page 66: Toad Users Guide

66

Execute SQL Scripts

The SQL Edit window can process SQL scripts that contain DDL statements, Insertstatements, and more. Some SQL*Plus commands are ignored as TOAD processes aSQL script. These commands include Describe, Show Errors, Set, Remark, andPrompt. For scripts that contain other SQL*Plus commands, you can still executeyour script using the SQL-Window > Execute SQL Window via SQL*Plus menuitem.

As TOAD processes a SQL script, you can also embed one script within another viathe “@” sign. For example,

REM This is the start of my script.

insert into table values (1);

@c:\scripts\doscript.sql

insert into table values (2);

etc.

Page 67: Toad Users Guide

Chapter 6 SQL Editor 67

Table/View Aliases

Setting up table or view aliases permits a shortcut for entering columns of a query.

The ALIASES.TXT file is in the TOAD\TEMPS directory. It should look like this:

table_name=alias

such as:AAX_ACCESSGROUP_APPLICATION=aax

ACA_ACTIVITY_ACTION=aca

ACC_ACTIVITY_CATEGORY=acc

ACD_ACTION_DESCRIPTION=acd

ACP_ACTIVITY_CONTACT_PARTIC=acp

ACT_ANALYSIS_CATEGORY_TYPE=act

ADD_ADDENDUM=add

ADT_ADDRESS_TYPE=adt

AFP_ACTIVITY_FIRM_PARTIC=afp

AGX_APPLICATION_GROUP_ITEM=agx

DEPARTMENT=dept

No ini changes are required. To use, simply type something like:

select dept.

and a column list will popup for the DEPARTMENT Oracle table.

Also, if you set up these table aliases in ALIASES.TXT, then they will be presentedon the SQL Modeler dialog when you select that table to build your query.

To complete the SELECT SQL statement above, use Auto Replace Substitutionsnamed similarly to the table aliases. These are accessible through the Edit > EditorOptions > Auto Replace tab. However, it would take you a long time to add areasonably sized schema, so it is recommended that you edit\TEMPS\PLSQLSUB.TXT. It should look like this:

Page 68: Toad Users Guide

68

aax_ = AAX_ACCESSGROUP_APPLICATION aax

aca_ = ACA_ACTIVITY_ACTION aca

acc_ = ACC_ACTIVITY_CATEGORY acc

acd_ = ACD_ACTION_DESCRIPTION acd

acp_ = ACP_ACTIVITY_CONTACT_PARTIC acp

act_ = ACT_ANALYSIS_CATEGORY_TYPE act

add_ = ADD_ADDENDUM add

adt_ = ADT_ADDRESS_TYPE adt

afp_ = AFP_ACTIVITY_FIRM_PARTIC afp

agx_ = AGX_APPLICATION_GROUP_ITEM agx

dep_ = DEPARTMENT dept

i.e., string = string to replace it with

You might want to use the underline _ because it is not as likely that a command willend with the underline _ symbol. Having the alias afterwards keeps it tidy. So, if youtype:

select dept.

the popup should appear. Select your column name, then continue.

select dept.NAME

from dep_

press spacebar and it autocompletes...

select dept.NAME

from DEPARTMENT dept

If you edit ALIASES.TXT or PLSQLSUB.TXT, be sure to close and reopen TOADto re-read the list.

An alternative to using AutoReplace for tablenames is tablename completion. Forexample, if you type dep and press <CTRL>. (period), a list of all tables beginningwith dep will popup.

Page 69: Toad Users Guide

Chapter 6 SQL Editor 69

Configuring the Editor

The editor in TOAD is used on the SQL Editor and Procedure Editor windows to editSQL text. The same editor is used in read-only mode on many other windowsthroughout TOAD. This section highlights some of the configurable features. TheEditor Options, which includes some of the following options, are discussed in detailin the next section. Right-Click Options are also discussed in detail in the Right-Click section of this chapter.

� User configurable Syntax Color Highlighting

The editors in the SQL Edit and Procedure Edit windows support flexible syntaxhighlighting. The highlighting is configurable in the Editor Options window and thelist of reserved words used in each window is also customizable by editing the parserscript file. If during a TOAD session you have used any window or function thatretrieves the tablenames for the active Oracle session, tablenames will be colorizedas well.

In order for the editor to support syntax highlighting, the following files distributedwith TOAD must be located in the TOAD\TEMPS directory:

PLSQLSCR.TXT, for syntax parser scriptsPLSQL.DCI, for code templates

Page 70: Toad Users Guide

70

Here, the default color of green for comment is being changed to light blue and italics has been unchecked.

Page 71: Toad Users Guide

Chapter 6 SQL Editor 71

Editor Parser Scripts

The primary configuration for the editor comes from an editor parser script text filethat is loaded at runtime. This file is editable but be VERY careful if you decide toedit this file because NO technical support for altered scripts will be provided.

The particular editor parser script is determined from the language of the object inthe editor buffer. In the SQL Edit window editor, this language is always PLSQL. Inthe offline text editor, you can also have languages HTML, INI, JAVA, and TEXT.The language is determined from the file extension, e.g., HTML, and is configured inthe TOAD Options > Files > Language / File Associations grid.

The list of languages and editor parser scripts is:

Language Editor Parser Script File

HTML HTMLSCR.TXT

INI INISCR.TXT

JAVA JAVASCR.TXT

PL/SQL PLSQLSCR.TXT

TEXT TEXTSCR.TXT

All editor parser script files are stored in the TOAD\TEMPS folder.

Long and Short PL/SQL Editor Parser Scripts

There are two flavors of the PL/SQL editor parser script installed for your selection:SHORTSCR.TXT and LONGSCR.TXT. SHORTSCR.TXT is the same asPLSQLSCR.TXT. LONGSCR.TXT contains more items to syntax highlight andmight perform slower, depending on your editor contents. The additional 200 itemsin LONGSCR.TXT are commonly used package functions and procedures in theSYS schema, such as DBMS_OUTPUT, DBMS_PIPE, DBMS_JOB, DBMS_SQL,DBMS_STANDARD, and DBMS_UTILITY. Each additional item to syntaxhighlight takes a little more execution time. If you want to utilize theLONGSCR.TXT parser script file, copy LONGSCR.TXT over PLSQLSCR.TXT. Ifyou want to restore the shorter format for the editor parser script file, copySHORTSCR.TXT over PLSQLSCR.TXT.

Page 72: Toad Users Guide

72

If you want to add or remove Oracle SQL Reserved words, PL/SQL Reserved words,or Oracle Keywords from the lists that are syntax highlighted, then edit thePLSQLSCR.TXT file. If you want to add or remove words from the syntaxhighlighting of the other languages, edit the corresponding editor parser script forthat language.

� Bookmarks

Bookmarks help you manage files. They are especially useful when you are trying tomanage large files. Mark a position within the SQL Editor so that you can easilyjump back to that line. You can set up to 10 separate bookmarks within one editor.

Bookmarks can be accessed from the Right-Click Menu.

To set a bookmarkPress <CTRL><SHIFT># where # is a number between 0 and 9. A small green boxcontaining the bookmark number will appear in the editor gutter.

To jump back to a bookmarkPress <CTRL># where # is a previously defined bookmark between 0 and 9.

Note that these keystrokes assume you have not altered the default editor keys. Referto the Key Assignments topic, page 95, for more information.

Once a file is closed, the bookmarks are reset.

� User defined keystrokes for common editing commands

Click Edit > Editor Options > Key Assignments to access the Key Assignmentswindow.

Select the command from the left panel and its associated Key Assignment displaysin the right panel. The Add or Edit buttons display easy-to-follow steps so that youcan add new key assignments or edit existing ones. The Delete button deletes thehighlighted key assignment. See the Key Assignments topic, page 95 , for moreinformation.

Page 73: Toad Users Guide

Chapter 6 SQL Editor 73

� Auto Replace Substitutions

A substitution is a text phrase that corresponds to replacement text. For example: ifyou specify a substitution pair of ACT = ACTIVITY_CENTERS, when you typeACT and press <SPACE> (or other configurable word delimiters), ACT isautomatically replaced by ACTIVITY_CENTERS. If you specify a substitution pairof NDF = NO_DATA_FOUND and you type NDF and press a delimiter, NDF isautomatically replaced by NO_DATA_FOUND.

To access Auto Replace go to the Edit > Editor Options > Auto Replace tab.TOAD already has a few Auto Replace Substitutions specified: teh = the, ndf =NO_DATA_FOUND, (c) = ©.

The TOAD parser scripts come with a handful of Substitution pairs but you may editand add to the list on the Editor Options window. Once saved from this window, thesubstitution pairs will be saved to an ASCII file named [Language]SUB.TXT in theTEMPS directory.

The Auto Replace substitutions for each language type are stored in separate files inthe TOAD\TEMPS folder.

Language Auto Replace Substitution File

HTML HTMLSUB.TXT

INI INISUB.TXT

JAVA JAVASUB.TXT

PL/SQL PLSQLSUB.TXT

TEXT TEXTSUB.TXT

Thereafter, you can continue to alter the substitutions in the Editor Options windowor directly in the [Language]SUB.TXT file.

Page 74: Toad Users Guide

74

� Code Completion Templates

Code templates expand upon the Auto Replace Substitution concept but a manualkeystroke (<CTRL><SPACE>) is required to perform the substitution. Codetemplates are more than a single phrase and can contain line feeds. If a vertical pipecharacter is in the code template, the cursor will be placed at that point in thetemplate. Code templates are loaded from the text file [Language].DCI from theTOAD\TEMPS folder, where [Language] can be HTML, INI, JAVA, PLSQL, orTEXT.

Example: one of the code templates defined in PLSQL.DCI is

[crbl | entire cursor block]

DECLARE

CURSOR c1 IS

SELECT | FROM WHERE;

c1rec IS c1%ROWTYPE;

BEGIN

OPEN c1;

LOOP

FETCH c1 INTO c1rec;

EXIT WHEN c1%NOTFOUND;

END LOOP;

CLOSE c1;

END;

Where:"crbl" is the macro for the template (the text YOU type)"entire cursor block" is the description of the templateeverything following until the next template is the body of the template

NOTE:Do not leave spaces between the end of the template description andthe final right bracket! NT4.0 API calls to manage profile strings havea bug which will cause reading of the templates file to fail.

If you type "crbl" and press <CTRL><SPACE>, TOAD will load the body of thetemplate and place the cursor at the position of the vertical pipe char. If the word orphrase under the cursor does not match an existing macro verbatim, a dropdown listof all macros is displayed.

Page 75: Toad Users Guide

Chapter 6 SQL Editor 75

\TEMPS\PLSQL.DCI contains sample templates which you can alter to suit yourneeds.

You can edit the code completion templates directly in the Editor Options dialog,Code Templates tab, or via text editor on the *.DCI files.

� Undo/Redo

These basic editing commands are accessed from the Edit menu.

Command Keyboard Shortcut

Undo <CTRL>ZRedo <SHIFT><CTRL>Z

� Comment Code Block

This function comments the selected block of text by adding "--" before each line.This is available on the Right-Click Menus of the editors and is also on the MainEdit menu.

� Uncomment Code Block

This function uncomments the selected block of text by removing "--" from thebeginning of each line. This is available on the Right-Click Menus of the editors andis also on the Main Edit menu.

� Locate Closing Parenthesis (Find Closing Block)

Finds the closing parenthesis, "END" for matching "BEGIN", or "END IF" formatching "IF.”

If you select/highlight a left parenthesis, "BEGIN", or "IF", this function will showthe matching right parenthesis, "END" or "END IF."

Find Closing Block can only be accessed on the Right-Click Menus of the SQLEditor and Procedure Editor.

Page 76: Toad Users Guide

76

� Find, Find Next, Find Previous, and Replace

You access the Find and Replace editing options from the Edit menu.

Function Keyboard Shortcut

Find <CTRL>FFind Next F3Find Previous <SHIFT>F3Replace <CTRL>R

� Show All following a search

To get to this function click Edit > Show All.

Only to be used after a FIND. After you use FIND to search through your text, for aword or phrase, you can click Show All from the Edit menu and Show All willdisplay wavy red lines under every occurrence of the search phrase. The lines will beremoved following any change to the text in the editor.

� Configurable Print Options

To get to the Print Options click Edit > Editor Options > Options tab.

Use Syntax Highlighting when Printing Source Code

This option is checked by default, which means the report will print using the samecolors that are displayed in the window. So, color printing is the default for printingSQL Edit text or Stored Procedure Edit code.

If you uncheck the View > Options > Printing tab option Use Syntax HighlightingWhen Printing Source Code then the SQL text or Stored Procedure Edit code willbe printed in standard black and white.

If you get garbage characters on your color printout, turn off Syntax HighlightingWhen Printing Source Code and then try to print again.

Page 77: Toad Users Guide

Chapter 6 SQL Editor 77

The Reports Font

The Reports Font dialog is in View > Options > Printing.

You can change the reports font. The default font is courier, regular, 9 point. Youcan click the drill down button to the right of the Reports Font textbox to display thefonts selection menu. After you’ve selected your new fonts click OK. If you clickCancel, your reports font will not change.

The drill down button lets you change the reports font.

Page 78: Toad Users Guide

78

Editor Options

Editor Options can be selected, deselected, and modified on the popup dialogwindow that is available either from the Right-Click Menu of the editor (on the SQLEdit or Procedure Edit windows) or from the Edit menu > Editor Options in a SQLEditor or Procedure Editor window.

The Editor Options lists categories in the left panel: General Options, Highlighting,Key Assignments, Auto Replace, and Code Templates. Click any of these items todisplay its corresponding options in the right panel.

The editor options are stored in the [Language]KEYS.BIN and[Language]OPTS.TXT files in the TOAD\TEMPS folder, where [Language] is eitherHTML, INI, JAVA, PLSQL, or TEXT. When a change is made to the editor options,the appropriate OPTS.TXT and KEYS.BIN files are written out. Do not attempt toedit these files with a text editor. Use the Editor Options dialog.

Language Editor Options Files

HTML HTMLKEYS.BIN HTMLOPTS.TXT

INI INIKEYS.BIN INIOPTS.TXT

JAVA JAVAKEYS.BIN JAVAOPTS.TXT

PL/SQL PLSQLKEYS.BIN PLSQLOPTS.TXT

TEXT TEXTKEYS.BIN TEXTOPTS.TXT

NOTE:

The Key Assignments, Auto Replace, and Code Templates items have Load fromFile and Save to File buttons. Each of these buttons lets you set up two or morecollections of keystrokes, auto replaces, and code templates. This is useful on multi-user machines. For example, one user might prefer to use one set of assigned keys,auto replaces, and code templates, and another user might have a different set for apreference.

Page 79: Toad Users Guide

Chapter 6 SQL Editor 79

General OptionsClick the General Options item to display the collapsed categories in the right panel.

General Options lists four categories:Printing OptionsDisplay OptionsControl OptionsGeneral Options

Page 80: Toad Users Guide

80

Click the “+” next to each option to expand its corresponding checklist.If the checklist is expanded, click the “–” to close the corresponding checklist.

Here, the Printing Options list is expanded. A click on the minus sign willcollapse the list. A click on the pluses in the other options will expand theircorresponding lists.

Page 81: Toad Users Guide

Chapter 6 SQL Editor 81

Printing OptionsThese options are used when you print the editor comments to paper.

Wrap lines when printing

Default – Checked

When checked this option automatically wraps lines when printing.

Print line numbers

Default – Checked

When checked, this option prints the line numbers.

Print filename in header

Default – Checked

When checked, this option prints the filename in the header.

Print date in header

Default – Checked

When checked, this option prints the date in the header.

Print page number

Default – Checked

When checked, this option prints the page numbers on your printout.

Page 82: Toad Users Guide

82

Display OptionsThe display options allow you to control what is displayed in the editor.

Display line numbers in gutter

Default – Unchecked

When checked, this option will display line numbers in the gutter, which is a verticalregion to the left of the editor used to display bookmarks, breakpoints, line numbers,and allow for multiple line selection with the mouse. If unchecked, line numbers willnot display. You may want to increase the width of the gutter, in the Gutter Widthtextbox, to display large line numbers.

Show right margin

Default – Unchecked

When checked, this option displays a light gray vertical line indicating the rightmargin. When unchecked, no line to indicate the right margin will appear.

In the SQL Editor or Procedure Editor, you can also drag and drop the vertical rightmargin line left or right to change it.

NOTE: No word-wrapping occurs at the right margin line. Word-wrapping isdiscussed later in this chapter in the Show Word-Wrap Column section.

Show gutter

Default – Checked

When checked, this option displays the gutter. When unchecked a gutter does notdisplay. So, if you have chosen to display line numbers but you have the Show gutteroption unchecked, your line numbers, which would display in the gutter, will notdisplay.

Gutter

Page 83: Toad Users Guide

Chapter 6 SQL Editor 83

Show word-wrap column

Default – Checked

When checked, this displays the word-wrap column, which is basically a dashedvertical gray line on the right side. You have to enter a value in the word-wrapcolumn value box in order for this to display. The default is 0, which means noword-wrap column will display. So, you need to check the Show word-wrapcolumn checkbox AND enter a value in the word-wrap column box. For example, ifyou enter 20, a dashed vertical line displays in column 20, and any lines longer than20 characters will wrap. The vertical word-wrap line can be dragged and dropped tothe left or the right, so you don’t have to drill down to the editor options dialog whenyou want to change the column settings. Word wrapping will not begin until you alsocheck the General Options > Word Wrap Lines checkbox.

Block cursor on overwrite

Default – Checked

If this option is checked when you press the insert key to change to overwrite mode,the cursor is displayed as a block because it’s in overwrite mode, providing a visualreminder that it’s in overwrite mode. If the option is unchecked the cursor remainsunchanged when you switch to overwrite mode, as opposed to changing to a block.

Show wrapped lines with the |> arrow glyph

Default – Checked

If checked, this option displays a glyph |> in the gutter for wrapped lines.

Page 84: Toad Users Guide

84

Show Control Characters

Default – Unchecked

If checked, the control characters (such as paragraph marks, end-of-line characters,spaces, and TABs) will display onscreen in your scripts.

Apply capitalization effects

Default – Unchecked

When checked, this option will apply the capitalization effects that you select fromthe Highlighting Options section.

Page 85: Toad Users Guide

Chapter 6 SQL Editor 85

Control Options

Allow TCustomSyntaxMemo to be an lDragSource

Default – Checked

When checked, this option lets you select and drag text from one editor to anotherwindow application or another TOAD window.

Title as Load/Save Filename parameter

Default – Checked

This causes the file title to be the name when saving and loading the file.

Track columns in vertical movement

Default – Checked

If this is checked, the editor will attempt to restore the current column position asyou key up or down through the lines of text. If the text is wide enough then thecurrent column position is maintained, otherwise it places the cursor at the end of theline.

If this is unchecked, as you key up or down through the lines of text, the cursorcolumn position decrements as the lines of text get shorter.

Respond to dropped files

Default – Checked

If checked, this lets files be dragged and dropped from Explorer to a TOAD editor.

Override word-wrap based on line start char

Default – Unchecked

You can specify a character or characters on the Editors Options dialog ,Word-Wrap Override Chars textbox, that will override word wrapping for that line only.

So, if you want to specify that “>” will override word wrapping for a line, enter it,set word-wrap to column 16, and you’ll get:

Page 86: Toad Users Guide

86

This is over 16 chars

and will word wrap

but when you begin the line with your specified character “>”

>This is over 16 chars and will not word wrap.

Page 87: Toad Users Guide

Chapter 6 SQL Editor 87

General Options

Auto indent

Default – Checked

If you have an indention already set, when you type, it automatically indents thefollowing lines.

Tab to next column

Default – Checked

When checked, the <TAB> key moves the cursor to the next column.

Auto select word on double-click

Default – Checked

When checked, if you double-click on a word in the editor it becomes selected.

Insert TABs into text for TAB chars

Default – Checked

Tabs are inserted into the text when the <TAB> key is pressed. Otherwise, anappropriate number of spaces are inserted.

Insert mix of TAB/SPACE for optimal fill

Default – Checked

If checked, the editor will fill the required gap with a minimum number of characterscomposed of TABs and spaces.

Type this:This line of code starts in column 5

So does this line

Page 88: Toad Users Guide

88

If the option is checked you get this:

this line of code starts in column 5

<TAB><SPACE>so does this line

Unchecked, you get this:

this line of code starts in column 5

<SPACE><SPACE><SPACE><SPACE>so does this line

Cursor beyond EOL

Default – Unchecked

When checked, you can type text or move the cursor past the right edge of each lineof text.

Word-wrap lines

Default – Unchecked

When checked, text will automatically wrap at the Word-wrap Column margin. Ifthis option is selected you cannot type beyond the right margin even if the cursorbeyond EOL option is checked.

Page 89: Toad Users Guide

Chapter 6 SQL Editor 89

Highlighting

The highlighting options are designed to allow you to select colors, fonts, and evencapitalization preferences for different items, names, etc. in the current schema. Forexample, Reserved word refers to Oracle reserved words. You can change theforeground or background colors for Reserved words, the font, the type size, andeven the capitalization. This lets you customize the way your code will appear forwhatever is easiest for you to read. A preview pane is provided in the lower part ofthe window that shows you how the selections you make affect the preview example.

Here, the underline option is checked for datatypes. In the preview screen, the datatype is underlined.

Page 90: Toad Users Guide

90

The following items can be syntax highlighted independently:

� Reserved Words

� SQL Functions

� Default Packages

� Exceptions

� Comments

� Identifiers

� Strings

� Numbers

� Symbols

� Datatypes

� Tablenames

� SYS Views

� SQL Reserved Words

� PL/SQL Reserved Words

� Default Exceptions

� User Procedure Names

For example, you could syntax highlight SYS view names like this:

And the result would be “Table_Privileges” in light red, initial caps.

You can syntax highlight tablenames in your schema applying different colors andcapitalization effects like this:

And the result would be “ALLOCATION” in light green, in all uppercase letters.

Page 91: Toad Users Guide

Chapter 6 SQL Editor 91

Display Item

This lists the display items from which you can choose to modify how they willappear. The last three display items, Selected Text, Left Margin, and Gutter, do notrefer to actual code content. They have only certain options enabled.

Selected Text

This is an item in the display items that refers to the colors that will display whenyou select text by either clicking and dragging the mouse over a section of text, orpressing <SHIFT> and one of the arrow keys to select a portion of text. You canchange both the foreground and background colors that will display for the selectedtext. You can preview your new selected text colors before clicking OK, by selectingtext in the preview window and seeing how the new colors affect the selected text.The other selection areas such as font are disabled when you click on the SelectedText item. Only the foreground and background color sections are enabled.

Left Margin

This item only enables the background color choice. If the background color defaultbox is already checked, the dropdown menu will be disabled. In such a case, youmust uncheck the default box to enable the dropdown menu. The dropdown menudisplays a color palette from which you can choose the color for the left marginvertical bar.

Page 92: Toad Users Guide

92

Gutter

This item only enables the background color choice. If the Use Default box for thebackground color is already checked, the dropdown button is disabled. In such acase, you need to uncheck the Use Default box so that the dropdown button isenabled.

Default

The default item lets you change the appearance of your default text if you want touse colors or fonts that are different from the defaults.

About the color palette

The dropdown button for the background and foreground colors displays a smallpalette with 20 colors from which you can choose. If you click the Other button, alarger palette displays that has 48 basic colors. You can also customize your owncolor choices by either clicking the crossbars in the large multicolored box that is inthe right half of the window, and drag the crossbars until your desired color displaysin the Color/Solid box OR manually entering the values for Hue, Saturation,Luminance, Red, Green, and Blue. Click Add to Custom Colors, and the new colorappears in the customized colors palette. Click OK and that color is selected forwhatever dropdown menu item you were on (Background color or Foregroundcolor).

Item Foreground

This option includes a dropdown list from which you can choose a color from thecolor palette. You can also click the Use Default box to the right of the dropdownbutton, to select the default foreground color. If the Use Default box is alreadychecked the dropdown button is disabled. In such a case, you must uncheck the UseDefault box so you can enable the dropdown button.

Page 93: Toad Users Guide

Chapter 6 SQL Editor 93

Item Background

Like item foreground, this option includes a dropdown list from which you canchoose a color from the color palette. You can also click the Use Default box to theright of the dropdown button to select the default foreground color. If the use defaultbox is already checked the dropdown button is disabled. In such a case, you mustuncheck the use default box so you can enable the dropdown button. If you are goingto change the item background make sure that it will have enough contrast from theitem’s foreground color to be easily readable.

Editor Font

This is a dropdown list of fonts that you can select. The default is Courier New.

NOTE: The editor supports only one font name for all display items.

Size

This is a dropdown list of point sizes that you can select. The default size is 10 point.

NOTE: Some fonts won’t have all the point sizes that are in the list. You need tolook at the preview window and see if your selection actually changes the size of thedisplay font.

B,I,U,S

These are checkboxes for bold, italics, underlined, or strikethrough text effects.Multiple checkboxes, or effects, can be selected for each item.

Character Set

This is a dropdown list of character sets from which you can choose. The default isANSI.

Capitalization Effect

This dropdown list lets you choose how your item will be capitalized. However, theApply Capitalization Effects checkbox that is in General Options > DisplayOptions must be checked in order for your capitalization effects to display.

Page 94: Toad Users Guide

94

Your choices are:Unchanged – No special capitalization will be applied.Lowercase – The item will appear in all lowercase letters.Uppercase – The item will appear in all uppercase letters.Initial Caps – The item will appear with only the first letter of each word in caps.

For object names that contain the underscore character, the first letter after theunderscore will be capitalized, too, e.g., Table_Name.

Capitalization effects are only applied to your text after you change lines up or downin the editor. E.g., type:

select * from table_name

and you will not get capitalization effects until you press <ENTER> or go up ordown one or more lines, then it is translated to:

SELECT * From Table_Name

Page 95: Toad Users Guide

Chapter 6 SQL Editor 95

Key Assignments

Clicking on the Key Assignments item displays the corresponding Key Assignmentsoptions. The Key command categories listed are:

BookmarksCaret movementClipboard operationsDeletion operationsMiscellaneous

Page 96: Toad Users Guide

96

Click the expand button to expand that category’s list

Select an item from the list and that item’s keyboard shortcut will display in theActivation Key Sequence window.

Add new sequence

This brings up a series of step boxes that let you add a new sequence by simplytyping the sequence in the step boxes.

Edit sequence

This lets you edit the existing sequence through a series of step boxes.

Delete sequence

This deletes whatever sequence is currently highlighted in the Activation keysequences window. If a list of sequences is in the box, you can click a sequence fromthe list to highlight it and then click the delete sequence button to delete thathighlighted sequence.

Page 97: Toad Users Guide

Chapter 6 SQL Editor 97

Auto Replace

Click on Auto Replace to display its corresponding options menu.

TOAD already has 5 Auto Replace items.

If type this Replaces with this(c) © (r) ® (tm) TM ndf No_Data_Foundteh the

Page 98: Toad Users Guide

98

Add definition

This box is enabled after you click in the Current selection window and type acharacter. The first blank window is where you type the text that you wantautomatically replaced. The window to the right is where you type the replacementtext. Then click the Add definition button to add this to the Auto Replace list.Remember to Click OK before exiting the window. If you exit the window withoutclicking OK the new definition will not be added.

Replace definition

This button is enabled after you make a selection from the already defined AutoReplace list and click in the With window (the right window under the currentselection window) and type a character in the With window. After you type the newentry that you want to replace the current selection with, click OK and the list will beupdated.

Delete definition

This button is enabled after you select a definition from the existing Auto Replacelist. Then click the Delete definition button to delete the definition from the list.Click OK and the definition will be deleted.

Auto Replace activation keys

; , : = [ ] \n \t \s

These keys will separate one word from another and trigger the editor to check forand replace one word for another. “\n” is a carriage return, “\t” is a <TAB>character, and “\s” is a space.

For example, if you type “this;that” then this will be autoreplaced when the “;” key ispressed.

The autoreplace items are saved and recalled from theTOAD\TEMPS\[Language]SUB.TXT file, where [Language] could be HTML, INI,JAVA, PL/SQL, or TEXT. You can directly edit the SUB.TXT file to add, delete, orchange the autoreplace substitutions without having to go through the Editor Optionsdialog.

Page 99: Toad Users Guide

Chapter 6 SQL Editor 99

Language AutoReplace File

HTML HTMLSUB.TXT

INI INISUB.TXT

JAVA JAVASUB.TXT

PL/SQL PLSQLSUB.TXT

TEXT TEXTSUB.TXT

Code Templates

Click the Code Templates item to display its associated options.

Shortcut/Description window

This window lists the code templates that are already defined.Click on an item from this window and its template will display in the displaywindow that is under the Shortcut/Description window.

Page 100: Toad Users Guide

100

Add definition

Click the Add definition button and a new line with the word new appears in theshortcut templates window. You can then type in the shortcut name. Then tab andtype in the description.

Delete definition

The Delete definition button is enabled when you click on a line from theShortcuts/Description window. To delete a definition, select theShortcut/Description you want to delete, click the Delete definition button, andthen click OK.

Code template items are saved and recalled from theTOAD\TEMPS\[Language].DCI file, where [Language] could be HTML, INI,JAVA, PLSQL, or TEXT. You can directly edit the .dci file to add, delete, or changethe code templates without having to go through the Editor Options dialog.

Language Code Templates File

HTML HTML.DCI

INI INI.DCI

JAVA JAVA.DCI

PL/SQL PLSQL.DCI

TEXT TEXT.DCI

Page 101: Toad Users Guide

Chapter 6 SQL Editor 101

Right-Click Menu

Click the right mouse button while you are in the SQL Editor to access the Right-Click Menu. This provides a shortcut to the functions listed in the menu.

You can also press F10 to display the Right-Click Menu.

The Right-Click Menu has a few features that are not anywhere else inTOAD. These functions are:

Search Knowledge BaseIf you’ve installed RevealNet’s Knowledge Base, you can easily accessand search the Knowledge Base through the Right-Click Menu.

Format SQLThis formats your SQL statements using RevealNet’s PL/Formatterproduct if installed or just a basic format if PL/Formatter is not installed.

Find Closing BlockFinds the closing parenthesis, "END" for matching "BEGIN", or "END IF"for matching "IF."

Optimizer mode for QueriesThis changes the optimizer mode for the entire session. Options includeChoose, Default, Rule, First Rows, and All Rows.

Page 102: Toad Users Guide

102

SQL Results Grid

The SQL Results Grid is for viewing output from select statements. The Grid letsyou take the results of a query and perform a variety of functions and displayoptions. It’s more flexible than using SQL* Plus, because you can format the resultsvisually or graphically. This section details some of the Results Grid features.

Visually, in the SQL Results Grid, you can:� Change the font

� Allow or disallow multi-selection of records

� Size the column widths to the width of the data

� Display row numbers in the record selector area

� Change the row height from single, to double or triple

If you type and execute

Select * from tablename

in the SQL Editor, you can see all rows and columns of the given table in the resultsgrid.

Rearrange Columns

You can drag and drop column names without having to re-execute your queries.

TOAD retains the column layout (order and widths) from query to query as long asthe column list in the query remains the same.

Editable Data Grid

The data grid that displays the results of the SQL queries is fully editable providingthat the query returns an updateable resultset. Query statements MUST return theROWID to be updateable.

Page 103: Toad Users Guide

Chapter 6 SQL Editor 103

For example:

select * from employee

would not be updateable whereas:

select employee.*, rowid from employee

would be updateable.

To overcome this obstacle, you can substitute EDIT Items which TOAD willtranslate into the updateable version of the statement.

For example:

edit employee

If the resultset is editable but remains read-only, make sure Read-Only on theOptions window is not enabled. This is a common FAQ concerning TOAD.

A red or green box displays in the status panel at the bottom of the SQL Edit windowindicating if the recordset is editable (green) or not editable (red).

Page 104: Toad Users Guide

104

Results Grid Right-Click Menu

The Right-Click Menu for the Results Grid provides numerous display, printing, andexporting options.

Memo Editor

The Memo Editor is for LONG, CLOB, or VARCHAR data type columns. Blob Editis for LONG RAW/BLOB data type columns. For columns that are long (200characters or more), when you double-click, a text editor displays. This is notdesigned for numeric columns. It’s designed for text. For date columns, a date pickeris displayed where you can select a date from a calendar presentation.

To view and/or edit the contents of a large column Memo EditIf the View|Options|Data Grids|Popup Memo Editor on Double-Click setting isON,

1 Double-click a column to edit its value in the Memo Edit popup window.

Otherwise,

1 Right-click to display the Right-Click Menu.

Page 105: Toad Users Guide

Chapter 6 SQL Editor 105

2 Click the Memo Editor menu item.

3 If you want to make changes to the data in the Memo Edit popup window, theresultset must be editable. Otherwise, the Memo Edit popup window is alsoread-only.

Print Grid

This invokes a grid print setup window where you can custom set the width of thecolumns, add headers, and custom set other page print options. Use this dialog toselect your grid print options, then print the grid contents to paper.

You can total a number column. Click on a Column in the Report will print asshown window. Check the Total the Column checkbox, and your column will betotaled.

Page 106: Toad Users Guide

106

The tabs in the Grid-Print Setup window are for Headers/Footers, Columns, andPage Setup.

Headers/Footers

You can select a top line and second line header and a one line footer.

You can also check the Print page numbers box and the page numbers will beprinted.

Page Setup

A dropdown button lets you select the printer.

Default orientation in the page setup is Landscape. Because the width of the screen isgreater than the width of Portrait orientation, you should print using Landscapeorientation.

TOAD does not have a print preview, so it is important to remember thatthe width of the screen is wider than the width of a portrait layout page.TOAD’s default print setting is Landscape Orientation.

Columns

A checkbox lets you print column titles in bold.

A dropdown list lets you choose left, centered, or right text alignment.

The Remove Column button lets you remove columns.

A dropdown list lets you choose left, centered, or right date alignment.

If you want to total a column, select the column in the Report will print as showndisplay and then check the Total this column checkbox.

To print the grid contents to paper1 From the Grid > Print Grid menu, or the Right-Click Menu over the SQL

results grid, select the Print Grid menu item.

2 The Grid Print Setup dialog window displays. There are tabs forHeaders/Footers, Columns, and Page Setup.

Page 107: Toad Users Guide

Chapter 6 SQL Editor 107

Because the screen fonts are slightly different from the printer fonts, it is best toleave space between columns so that the printed version has sufficient spacebetween columns.

After you select your options, click the Print button.

Save As

The Save As dialog from the Right-Click Results Grid menu displays the Save GridContents window which contains format and file location options.

Delimiters

Some programs require commas, which is a popular standard, to distinguish the datafrom one column to another column. The ASCII standard for dividing data is the<TAB> character. The Save As dialog from the Right-Click Results Grid Menu letsyou choose a comma delimiter, a tab delimiter, or you can enter a different delimitercharacter.

Page 108: Toad Users Guide

108

Format

Default – Tab Delimited

The Format area contains three radio buttons:

� Comma Delimited – Divides data between columns with commas

� Tab Delimited – Divides data between columns with tabs

� Other – You can type the character you want to use as a delimiter

Double Quote Text Characters

Default – Unchecked

If this option is checked, text will be enclosed in double quotes.Example:7369 "SMITH" "CLERK" 7902 12/17/1999

Include Column Header

Default – Unchecked

If this option is checked, the column headers will be included in the text output.

Example:EMPNO ENAME JOB MGR HIREDATE SAL

7369 SMITH CLERK 7902 12/17/1980 800

Include NULL Text

Default – Unchecked

If this option is checked, the word NULL will be included for empty cells (cells thatcontain no information).

Example:7698 BLAKE MANAGER 7839 05/01/1988 NULL 30

Page 109: Toad Users Guide

Chapter 6 SQL Editor 109

Save as HTML Table

If this choice is selected, TOAD generates <TR></TR> and <TD></TD> HTMLtags (tags for table rows and columns) and puts the values between the tags.

Save to (Save Grid Contents window)

Default – Clipboard

If you choose File, you can type in the file location or you can click the drill downbutton to find your target directory.

Save to Clipboard saves the text to clipboard ready for you to Paste to anotherapplication such as Word or Excel. After you click OK, TOAD will display aconfirmation message that states the number of rows that were exported.

To copy the rows to the windows clipboard, or save them to a file1 Right-click in the results grid and select the Save As menu item.

ORClick Grid > Save As menu item.

2 The Save Grid Contents window displays.

3 From the Save Grid Contents window, select your settings.

4 Click OK.

5 The data is copied to the clipboard or saved in a text file.

TOAD displays a confirmation message after it completesthe Save As process.

Page 110: Toad Users Guide

110

To temporarily hide selected columns1 Select the Select Columns item from the Right-Click Menu.

2 Uncheck the columns you want to hide. They will NOT be included when youcopy to clipboard or save to file.

This does NOT requery the data from the database. It just temporarily hides thecolumns.

To set the column widths to a custom width settingIf you want to see more or less of a column,

� Move the mouse pointer to the grid headings, over the border between 2columns, and drag it left or right.

If the columns of a query are the same from query to query, then TOAD retains thesecustom column widths. You could add a WHERE clause, or an ORDER BY, etc.,re-execute the query, and the column widths would remain the same.

If the columns of a query are different, then the grid columns will be sized accordingto the TOAD Options > Data Grids > Size Grid Columns to the Width of theData, and Allow Columns to be Less Then the Header Width.

Export to Flat File

When you Export to Flat File you export data to an ASCII file without columndelimiters. The spec file indicates start and end points for columns, which you canedit.

On the Options tab, select the table to export.

You must set up the Specifications File, which will define the table name, tableowner, how many lines in the output file will be covered by a single record of data,the columns of data, what line they will appear on, the starting column, and thelength of each column of data.

Spec File tab

This is where you set up where your columns will begin and end.

See the Generate Columns button section on the next page to learn how to create astarting point for your specifications file.

Page 111: Toad Users Guide

Chapter 6 SQL Editor 111

Spec FilenameYou can type in your filename or use the drill down to choose a target path.

ExecuteThis button exports the data to the file.

Save Spec FileThis saves your specifications file and all your edits.

Generate ColumnsThis creates columns for your specifications file based on the DDL for the table, notthe width of the actual table data.

Example of a specification file:

TABLENAME=EMPLOYEETABLEOWNER=DEMOLINESPERRECORD=1COL1=EMPLOYEE_ID,1,1,5COL2=LAST_NAME,1,6,15COL3=FIRST_NAME,1,21,15COL4=MIDDLE_INITIAL,1,36,1COL5=JOB_ID,1,37,4COL6=MANAGER_ID,1,41,5COL7=HIRE_DATE,1,46,22COL8=SALARY,1,68,10COL9=COMMISSION,1,78,10COL10=DEPARTMENT_ID,1,88,3

The basic format for the column definition lines is:COLx=COL_NAME,Output_row_num,Start Col,Num Columns

A sample flat file as exported will look like this:

7369 SMITH JOHN Q 667 7902 12/17/1984 800 20

7499 ALLEN KEVIN J 670 7698 2/20/1985 1600 300 30

7505 DOYLE JEAN K 671 7839 4/4/1985 2850 13

7506 DENNIS LYNN S 671 7839 5/15/1985 2750 23

Page 112: Toad Users Guide

112

More about Flat File

Flat File Export from Table window

You can also create a flat file from a table using the Database > Export > ExportTable as Flat File menu item. On the Options tab, you would select the schema andthe table to export.

Find Data

The Find Data window lets you search through selected columns for selected valuesor characters. You can specify whether you want the search case sensitive, andwhether or not you want to have partial matches.

To find data1 From the Right-Click Menu, or from the main Grid menu, select Find Data.

2 Select the column you want to search.

3 Enter the keyword or value to find.

4 Click the ADD button.

5 Select case sensitive and partial match options.

6 Click OK.

TOAD will search all records for the value, and position the recordset to the firstmatching value. If the records are cached then the search is fast. If TOAD needs toquery ahead in the recordset, then you’ll have to wait for additional rows to befetched from the database.

This dialog lets you enter a multiple column search criteria.Example:ENAME = ‘SMITH’ AND JOB = ‘CLERK’

Page 113: Toad Users Guide

Chapter 6 SQL Editor 113

Select Columns

You can check or uncheck the columns you want to see.You can also Select All or Unselect All

To rearrange the order 1 Select the column you

2 Drag the column(s) lef

3 If after rearranging youdata to a file, the data w

<ALT><RIGHT ARROW>columns at left unchanged. far right to the current colum

The Select Columns window

of the columnswant to move by clicking on its header.

t or right as desired.

r columns, you copy the data to the clipboard, or save theill be in the new column order.

will move the current column to the end, leaving the<ALT><LEFT ARROW> will move the column at the

n position.

Page 114: Toad Users Guide

114

For example, if you have the following columns:

1 2 3 4 5

Clicking on column 2 and pressing <ALT><RIGHT ARROW> will result in thiscolumn layout:

1 3 4 5 2

And pressing <ALT><LEFT ARROW> will take the column from the end and insertit into the current column position, yielding:

1 2 3 4 5

Copy Row

This item lets you copy an entire row.

To copy one row to create a new one1 Edit the recordset.

2 Click in a cell of the row you want to copy.

3 Select the Grid > Copy Row menu item (also accessible from the Right-ClickMenu).

4 This copies the entire row to the bottom of the SQL Results grid, ready for youto edit. NOTE: the recordset MUST be editable before the Copy Row functionwill work.

5 After you edit the cell contents, move to the row above in order for the row to besent to Oracle. If you want to cancel from adding this row, press the <ESC> key.

Record Count

This displays a count of the number of records in the recordset.

Page 115: Toad Users Guide

Chapter 6 SQL Editor 115

# Fixed/Anchored Columns

This displays a dropdown window where you can select 1, 2, 3, or the number youtype in Other. You can even select none. After selection, starting at the left, thenumber of columns you’ve selected are fixed and not editable. Horizontal scrollingin the grid will keep the fixed columns in view.

Row Height

This displays a dropdown window where you can select single, double, or triplespace row height. The default is single. The selection applies to all the rows in thegrid.

Allow Multi-Select

When this is checked you can select more than one row by pressing <CTRL> and therows you want to select. If you accidentally select a row you want to deselect, press<CTRL> and click the row and it will be deselected.

When Multi-Select is not checked you can only select one row at a time.

Font

This displays the font window where you can change the font for your Results Griddata. The font you choose is applied to all the data in the grid.

Size Columns to Data

When checked, this matches the column margins with the data.

Page 116: Toad Users Guide

116

Row Numbers

When checked, the Row Numbers display in the record selector area.

The total number of rows returned in the resultset will display in the status bar at thebottom of the window only after you have scrolled to the end of the resultset. This isbecause the resultset is fetched only as required, to improve overall performance.When the last row is fetched, TOAD will know and display the total count.

To return the Oracle pseudo-column ROWNUM in the SQL Results Grid, add"ROWNUM" to the query:

select rownum, emp.* from employee emp

Remember that rownum is an Oracle pseudo-column, not stored with the tabledefinition or data, but derived when queried.

To return the ROWID in the query, alias the column as another name:

select rowid foo, emp.* from employee emp

Row Highlight

When this is checked, the entire row is highlighted when any cell in the row isclicked. When this is unchecked, the individual cell highlights when selected.

Page 117: Toad Users Guide

Chapter 6 SQL Editor 117

Options for the Data Grids

The Data Grids options are accessed via the View > Options > Data Grids menuitem.

NOTE: Dates can only be entered in mm/dd/yy, mm/dd/yyyy, or the WindowsControl Panel, Regional Settings, Data, Short Data Style format. For example, inFrench, date entry of dd/mm/yy or dd/mm/yyyy is acceptable. Dates entered in dd-mon-yy format will be rejected.

Default to Read-Only Queries

Default – Unchecked

This option controls the ability to fetch updatable result sets in the SQL Editwindow. If checked, you cannot edit data in a SQL Edit window. You can edit aresultset by including the ROWID in the query, or using “edit table.”

Show row numbers in all grids (applies to data grids on Browser also)

Default – Unchecked

If checked, TOAD will display the row numbers in the results grid, records selectorsarea.

Popup memo editor on double-click

Default – Unchecked

If checked, when you double-click on any text column, a popup window will displaywith the contents. This option is useful for LONG columns.

Allow columns to be less than the header width

Default – Unchecked

If checked, you can resize the column widths to be smaller than the header text. Ifunchecked, the minimum you can resize the column width to is the width of thecolumn header text.

Page 118: Toad Users Guide

118

Size grid columns to the width of the data

Default – Unchecked

If checked, TOAD will size the column widths to the width of the data, or to thewidth of the column header, whichever is wider. If unchecked, TOAD will size thecolumn widths to a best guess.

Display (null) for Null columns

Default – Unchecked

If checked, TOAD displays “{null}” in the SQL Results Grid and Schema Browserdata grids for rows/cols that contain NULL.

Font for data grids textbox with drilldown

Default – Courier, Bold, 11

This is the font that the SQL Results Grid will use to display the data. The drilldownbutton accesses the standard font window. This option also affects the other grids inTOAD, like the Browser, Data tab.

Date format dropdown

Default – Your Windows Control Panel, Regional Settings, Short Date Style Format

Normally, the data in TOAD for date columns will display in the format selected inthe Window Control Panel. Selecting a different format will override the WindowsControl Panel setting.

Time format dropdown list

Default – h:mm:ss AMPM

This lets you select a different time format, if desired.

Clone SQL cursor when exporting grid contents (faster exports and uses lessmemory)

Default – Unchecked

Page 119: Toad Users Guide

Chapter 6 SQL Editor 119

If you clone cursor (check this option), TOAD will reissue the statement from theSQL Editor which means that the statement processing time is doubled. But thecursor is unidirectional, which saves a lot of memory during the export.

If you do not clone the cursor (unchecked), TOAD will use the existing cursor fromthe SQL Editor Grid, which is a lot faster, but can potentially be a memory hog.

Do not require NOT NULL columns in data grid entry (allow Oracle to enforceconstraints)

Default – Checked

If this option is checked, TOAD will not check for blank values during grid edits,and will instead rely on Oracle for the constraint checking. If unchecked, TOAD willstop editing if blank is entered in a NOT NULL required entry column.

Trim string data before posting to Oracle

Default – Unchecked

If checked, this will trim off trailing spaces from data before posting it to thedatabase. This lets you post a single column with just spaces.

Confirm deletions

Default – Unchecked

If checked, this will confirm each record deletion before deleting the record. Thisalso affects the data grids on the Schema Browser “Data” tabs.

Sliding window for entering two digit years

Default - 30

This is the number of years that will be subtracted from the current date (systemdate) to determine whether a two-digit year will be interpreted as a current centuryyear or a previous century year. Click the Up and Down arrow to select the range.The range of choice is 0 to 49. Anything outside of the sliding window will betreated as a current century year, and any number that falls inside the sliding windowwill be treated as a previous century year.

Page 120: Toad Users Guide

120

For example, if your current system date is set for June 1, 2000 and you specify a 30year window (which is the TOAD default) and enter 1/1/87, the date produced willbe Jan. 1, 1987; if you enter 1/1/57 that is outside of the 30 year window so the dateproduced will be Jan. 1, 2057.

Page 121: Toad Users Guide

Chapter 6 SQL Editor 121

LONG and LONG RAW

NOTE: LONG is similar to CLOB and LONG RAW is similar to BLOB, and TOADcan handle all four of these datatypes.

TOAD does not display the data for LONG RAW columns in a SQL Edit Grid.LONG columns are columns that contain character data up to 2 gigabytes. Youdefine them as “long” in your SQL script. LONG RAW columns contain binary datathat cannot be displayed such as GIFs, Word docs, etc.

LONG columns display the first several characters and LONG RAW columnsdisplay as (BLOB).

You edit these columns by double-clicking on the column and editing from thepopup windows that display. For LONG columns, the Memo Editor window isdisplayed. For LONG RAW columns the Blob Edit window is displayed. If thepopup window does not display, go to View > Options, on the Data Grids tab, andmake sure the Popup memo editor on double-click option is checked. It must bechecked for the above functionality to work.

LONG RAW columns display as (BLOB).

Double-click a LONG or LONG_RAW column todisplay the popup memo editor.

Page 122: Toad Users Guide

122

The popup editor for LONG columns displays the column text. You can edit in theeditor or load a file into the editor. The popup editor for LONG RAWS providesLoad From File or Save to File functionality.

Load From File lets you select a file from your hard drive and place it into theLONG RAW column in the Oracle database.

Save To File lets you take the data from the LONG RAW column from the databaseand save it to a file on your hard drive.

Note that the recordset has to be editable for the popup editors to edit the data. Youcan still use the popup editors to have a read-only view of the data.

Double-clicking on the LONG COLUMN$define popups a memo editor thatcontains the column text.

Page 123: Toad Users Guide

Chapter 6 SQL Editor 123

To Edit LONG and LONG RAW Columns

LONG Columns

The recordset has to be editable for the popup editors to edit the data.

1 Create a table: "create table long_test (id number, long_col long)"

2 Edit the table: "edit long_test"

3 Insert a row: enter “1” for ID, then double-click on the long col cell

4 Enter text.

5 Click the right arrow. "select * from long_test" should view all records,including (at least the first few chars) the long cols.

LONG RAW Columns

1 Create a table: "create table long_raw_test (id number, long_raw_col long raw)"

2 Edit the table: "edit long_raw_test"

3 Insert a row: enter “1” for ID then double-click on the long raw col cell

4 Pick a file to import.

5 Click the right arrow Next Record button. "select * from long_raw_test" shouldview only id, long_raw_col should display (BLOB).

Page 124: Toad Users Guide

124

Time ValuesWhen displaying times with dates, TOAD suppresses the time values if they are12:00:00 AM (midnight). The time portion of the date fraction is zero, so TOADadds no value to the display of the date.

Oracle stores dates as a big fraction number offset from January 1, 4712 B.C. It isthen converted to a complete date, and time. Whether or not you use time, it's inthere. It will also work accurately well past Y2K.

Performing a query:

SELECT SYSDATE FROM DUAL

will display the time, and similarly, queries of DATE datatype columns will displaythe time if it is not midnight.

The time dropdown in the TOAD Options > Data Grids dialog is for displaypurposes and does not affect the storage of time values.

Page 125: Toad Users Guide

Chapter 6 SQL Editor 125

SQL TemplatesSQL Templates (Help) is a popup reference for Oracle SQL functions andexpressions. To access the SQL Help Templates, go to the common edit toolbar inthe SQL Edit window and select Show SQL Help. You can also access SQLTemplates from the Procedure Editor window.

The items’ associated text files are located in the TOAD directory in the TEMPSfolder. You can modify the files.

STRFUNCS.TXT Single Row Character Functions

NUMFUNCS.TXT Single Row Number Functions

GRPFUNCS.TXT Group Functions

DATFUNCS.TXT Date Functions

DATEFMTS.TXT Date Format Options

CNVFUNCS.TXT Data Conversion Functions

MSCFUNCS.TXT Other Misc. Functions

NMBRFMTS.TXT Number Format Options

PSEUDO.TXT Oracle Pseudo Columns

OPTHINTS.TXT SQL Optimizer Hints

PREDFXCP.TXT Defined Exceptions

USRFUNCS.TXT User Provided Function List

FILE NAME ASSOCIATED TEMPLATE

These templates are user configurable by editing the textfile. This is especially useful for configuringPREDFXCP.TXT and USRFUNCS.TXT.

In the SQL Templates window, an explanation ofthe item or function displays in the lower panel.The items can be dragged and dropped into yourSQL script.

Page 126: Toad Users Guide

126

To Access and Use SQL Help Templates1 Click the Show SQL Help button that is located on the common edit toolbar.

2 Select an item from the dropdown list.

3 An explanation of the item or function will display in the lower panel.

4 You can drag and drop the item to your SQL Editor.ORYou can click the Direct button to automatically copy and paste the item intoyour SQL script.ORYou can click the Clipboard button to copy the item to the clipboard.

Show SQL Help

Page 127: Toad Users Guide

Chapter 6 SQL Editor 127

DBMS_OUTPUT to Debug PL/SQL Code

When you turn on an embedded DBMS_OUTPUT window, the SQL Editor is ontop, in the lower left is the DBMS_OUTPUT window, and on the lower right is theSQL Results Grid. You can have the DBMS_OUTPUT window as either embeddedin the SQL Edit window or as a separate MDI child window. With the MDI child,both the SQL Edit window and the DBMS_OUTPUT window are the same size, andcan then be tiled, cascaded, etc. The DBMS_OUTPUT is discussed in detail in thePL/SQL Debugger chapter.

Display/Close Embedded DBMS Output window

Page 128: Toad Users Guide

128

Make Code Statement and Strip Code Statement

The SQL Edit window contains two functions that simplify copying SQL statementsfrom TOAD to code development tools such as Delphi, VB, C++, Java, or Perl, andfrom those code development tools back to TOAD. The functions are called MakeCode Statement <CTRL>M and Strip Code Statement <CTRL>P.

Make Code Statement

Adds the code development tool syntax to the SQL statement in the SQL Editor, andmakes it ready to paste into the development tool code.

When making code statements, rather then changing the code in the SQL Editwindow as the Strip Code Statement function does, the Make Code Statementfunction takes the currently highlighted SQL statement, translates it into the codedevelopment tool syntax, and copies it to the clipboard. You can now switch to thecode development tool, and paste in the results. A message displays in the statuspanel such as “VB statement copied to the clipboard.”

If you have multiple SQL statements in the SQL Editor, highlight the statement youwant to make before executing the Make Code Statement function.

For example, taking this code and running Make Code Statement for VB code,changes the SQL statement from this:

select count(*) as cnt

from all_tables

where owner = 'DEMO'

and table_name = 'EMPLOYEE'

to this:

Sql = " select count(*) as cnt"

Sql = Sql & " from all_tables"

Sql = Sql & " where owner = 'DEMO'"

Sql = Sql & " and table_name = 'EMPLOYEE'"

Page 129: Toad Users Guide

Chapter 6 SQL Editor 129

Strip Code Statement

Strips off the code development tool syntax from the SQL statement, ready toexecute in TOAD.

For example, taking this VB code from the VB development tool, copying it, pastingit into TOAD, and running Strip Code Statement, changes the SQL statement fromthis:

Sql = " select count(*) as cnt"

Sql = Sql & " from all_tables"

Sql = Sql & " where owner = 'DEMO'"

Sql = Sql & " and table_name = 'EMPLOYEE'"

to this:

select count(*) as cnt

from all_tables

where owner = 'DEMO'

and table_name = 'EMPLOYEE'

Now the SQL is ready to execute in TOAD.

If you have multiple SQL statements in the SQL Editor, highlight the statement youwant to strip before executing the Strip Code Statement function.

Selecting the Code Development Tool

You select the code development tool in theView > Options > SQL Editor tab > Make Code Format dropdown list.

The Make Code format dropdown list

Page 130: Toad Users Guide

130

The Make Code Format dropdown list lets you select a language syntax for TOADto convert a SQL statement into (Make Code Statement function) and out of (StripCode Statement function). Currently, Delphi, VB, C++, Java, and Perl are supported.The default selection is VB.

External Editor

You can use an external editor to edit the SQL Editor contents. To set up, go to theTOAD Options > Editors > External Editor Command Line. Enter the driveletter, path, and executable name of the external editor you want, e.g.,c:\winnt\notepad.exe. While in the SQL Editor or Procedure Editor, press <F12> toinvoke the external editor, which will start and load up the current TOAD Editorcontents. Use the external editor, save the contents back to the SQLPLS.SQL file inthe TOAD folder, quit the external editor, click back on TOAD, which will ask youif you want to reload the contents of the SQLPLS.SQL file. Select Yes.

Page 131: Toad Users Guide

Chapter 6 SQL Editor 131

Options for the Editors

You access this menu via View > Options > Editors menu item.

Show Views on Table Selector

Default – Unchecked

If checked, will show views, along with tables, on the Table Select window. Tablesare listed on one tab, and Views are on a separate tab.

Show Synonyms on Table Selector

Default – Unchecked

If checked, will show synonyms, along with tables, and optionally views, on theTable Select window. Tables, Views, and Synonyms are listed on separate tabs.

Use syntax highlighting on tablenames

Default – Checked

If checked, will show tablenames in the SQL Edit window and other editors, usingthe syntax highlighting feature. If unchecked, tablenames will appear in black text.

Treat underbar character as part of object names

Default – Unchecked

If checked, will select the entire word when double-clicked, including characters tothe left and right of the underscore character, "_". If unchecked, will select only theportion of the double-clicked word up to the underscore character.

Display columns dropdown list after typing object name followed by a period

Default – Checked

If checked, will display the columns dropdown list. If unchecked, will not display thecolumns dropdown list.

Page 132: Toad Users Guide

132

Return column names in lower case from Selection Windows (and drag-drop)

Default – Unchecked

If checked, will return selected column names into the editors in lower case.Otherwise they are returned in upper case.

Allow RTF when copying to/from clipboard

Default - Checked

If checked, TOAD will copy color markups, for pasting into email or other RTFenabled applications. If unchecked, the text will be copied to the clipboard asstandard black text.

Show Editor toolbars on SQL Editor and Procedure Editor

Default - Checked

This option displays the editor toolbars on the SQL Editor and Procedure Editorwindows when checked. If unchecked, the editor toolbars will not display.

Use popup windows when executing DESC statements

Default – Checked

If checked, TOAD will present you with a popup window of complete object detailwhen executing a "DESC object_name" statement. If you prefer the results to bepresented in the SQL Results grid, then uncheck this option. Regardless of thisoption setting, selecting an object and pressing F4 will use the popup windows.

Use StayOnTop Popups

Default – Checked

If checked, the F4 popup Object Describe windows will use the windows Stay onTop feature.

Page 133: Toad Users Guide

Chapter 6 SQL Editor 133

Load the following from the TOAD.EXE\TEMPS location

Templates for new procedures in the Procedure Edit

Default – Checked

If checked, will load the NEWFUNC.SQL, NEWPACK.SQL, NEWPROC.SQL, andNEWTRIG.SQL new PL/SQL template files from the network or local workstationwhere TOAD.EXE and TOAD.HLP are running from.

Code Templates (Control-Space drop-downs) for editor windows

Default – Checked

If checked, will load TOAD.DCI code completion templates from the network orlocal workstation where TOAD.EXE and TOAD.HLP are read.

Source for the SQL Templates window

Default - Checked

If checked, will load the .TXT files that populate the SQL Templates window fromthe network or local workstation where TOAD.EXE and TOAD.HLP are read.

External Editor Command line

Enter the drive letter, path, and executable name of the external editor you want, e.g.,c:\winnt\notepad.exe. While in the SQL Editor or Procedure Editor, press <F12> toinvoke the external editor, which will start and load up the current TOAD Editorcontents.

Page 134: Toad Users Guide

134

SQL Editor TasksThis section will take you step-by-step through various tasks that you might want toperform with the SQL Editor.

To look up table columns while you construct a queryThis applies to any table or view that you can access, including objects from otherschemas, SYS, SYSTEM, etc.

1 After you type the table name (or view name) and the period, press <CTRL>T(or wait a few seconds)

2 A list of columns displays.

3 Click the item you wish to select. To select more than one item, hold down the<CTRL> key and click the items you wish to select.

Page 135: Toad Users Guide

Chapter 6 SQL Editor 135

4 Press <ENTER>.

5 TOAD places the selected column or columns into the SQL Editor to build yourquery.

select table_privileges.TABLE_NAME,TABLE_PRIVILEGES.SELECT_PRIV,TABLE_PRIVILEGES.INSERT_PRIV

After a query populates the SQL Results Grid, you can press <CTRL>T to display alist of the columns from the SQL Results Grid.

Page 136: Toad Users Guide

136

To copy Table Names into the SQL EditorYou can copy the Table, View, or Synonym names from the Table Name Selectdialog to the SQL Editor.

1 From a toolbar

2 The Tab

3 Click th<CTRL

4 You can

The Show Tables window button, in the common edit toolbar, pulls upthe Table Name Select window.

SQL Edit window or a Procedure Edit window, on the common editselect the Show Tables window button.

le Name Select window displays.

e item you wish to select. To select more than one item, hold down the> key and click the items you want to select.

drag and drop the item(s), or copy <CTRL>C and paste <CTRL>V.

The Table Name Select window

Page 137: Toad Users Guide

Chapter 6 SQL Editor 137

To copy Table Column Names into the SQL Editor

1 From the SQL Edit window or Procedure Edit window, on the common edittoolbar select the Show Columns window button.

2 The Column Name Select window displays.

3 Click the item you wish to select. To select more than one item, hold down the<CTRL> key and click the items you want to select.

4 You can drag and drop the item(s), or copy <CTRL>C and paste <CTRL>V.

The Show Columns button, in the second SQL Editor and Procedure Editortoolbar, pulls up the Column Name Select window.

The Column Name Select window

Page 138: Toad Users Guide

138

To get a description of an object while you are typing in the SQL EditorThis applies to Tables, Views, Procedures, Functions, and Packages.

1 Place the cursor on the object you want described.

2 Press F4.

3 A popup window displays that describes the object.

Page 139: Toad Users Guide

Chapter 6 SQL Editor 139

To use TOAD to copy Oracle data to another Windows applicationYou can query some data and process it further in another Windows application, likeExcel.

1 Execute a query, e.g. [select * from employee].

2 Right-click over the SQL results grid to display the Right-Click Menu.

3 Select the Select Columns menu item.

4 The Select Columns window displays.

5 Uncheck the undesired columns until the columns you want are the only oneschecked.

Page 140: Toad Users Guide

140

6 Select the Save As menu item from the Right-Click Menu. This saves theresults to the Windows Clipboard.

7 Check the Include Column Headers checkbox that is listed in the Save GridContents dialog.

Page 141: Toad Users Guide

Chapter 6 SQL Editor 141

8 Switch to the target Windows application, like Excel.

9 Paste in the results.

Page 142: Toad Users Guide

142

All the ways to get code into the SQL Editor

This section shows you the various ways you can enter or bring code into the SQLEditor.

Typing1 Start with a blank window in the SQL Editor.

2 Type in some SQL code.

3 Execute it.

4 Refine it.

5 Save it to disk.

Loading a file

1 Click

2 A Sel

3 Click

4 Click

5 The f

OR

Drag and

TaE

he Load a file into the editor button. You can click the triangle to display dropdown list of the last 10 files you opened while you were in the SQLdit window. Once the window is closed, the list is reset.

the Load a file into the editor button on the SQL Editor toolbar.

ect File SQL Edit window displays.

the desired file.

the Open button.

ile loads into the SQL Editor.

drop a file from Windows Explorer to the SQL Editor.

Page 143: Toad Users Guide

Chapter 6 SQL Editor 143

File > Reopen File

You can also open a file into the SQL Editor, or Procedure Editor, via the File >Reopen File menu. There is a list of the last 10 files opened. This list is saved andrestored to the file SQLFILES.TXT in the TOAD\TEMPS folder.

Page 144: Toad Users Guide

144

Recall previous SQL

1 SeleORPresORPres

2 Theyou

3 Sele

4 It is

On the Tcan choocheck thbecause

select

select

select

Another to save ato and refor more

Recall a

1 Ente

2 SeleORSele

3 The

4 Sele

T

Th

he Recall Previous SQL button

ct the SQL-Window > SQL Command Recall menu item

s F8

s the Recall Previous SQL button.

SQL Statement Recall window displays. It lists the last 100 queries thatexecuted in the SQL Edit window.

ct a query from the list.

copied to the SQL Editor.

OAD Options dialog View > Options menu item, SQL Editor node, youse to save only the SQL commands that executed without errors. To do this,e Save only statements that are valid checkbox. This is a useful filterotherwise the recall list will fill with queries until you get it right.

items from dept (invalid)

item from dept (invalid)

item from department (valid)

option lets you enter the number of previous SQL statements that you wantnd recall. The default is 100. The list of previous SQL statements is storedtrieved from SQLS.DAT. Refer to the Recall and Add SQL topic, page 55, information.

Personal SQL that you created

r a query.

ct menu item SQL-Window > Recall Personal SQLs.

ct the Recall Personal SQL button from the SQL Editor toolbar.

SQL Statement Recall dialog displays.

ct the desired SQL.

e Recall Personal SQL button

Page 145: Toad Users Guide

Chapter 6 SQL Editor 145

The list of personal SQL statements is stored to and retrieved fromPERSSQLS.DAT.

Recall a Named SQL statement that you created1 Enter a query.

2 Select menu item SQL-Window > Add to Named SQLs.

3 Enter a name, e.g., “Salary Query”

4 Select menu item SQL-Window > Recall Named SQL.ORPress <CTRL>N.

5 Select the query to return to the SQL Editor.

6 The SQL Statement Recall window displays. The queries are organized by thenames that you select.

The list of named SQL statements is stored to and retrieved fromNAMEDSQL.DAT.

Recall a Code Completion template that you previously set up1 Edit [Language].DCI in the TOAD\TEMPS folder, where [Language] could be

HTML, INI, JAVA, PLSQL, or TEXT.

2 Enter the shortcut keys for the code snippet, the complete name, and the code, inthe same format as the samples already in the .DCI file.

3 In the SQL Editor, type in the shortcut keys, e.g., “crbl”

4 Press <CTRL><SPACE>.

5 TOAD looks up the code completion template and plugs it into the SQL Editor.See the Code Templates topic, page 99, for more information.

Page 146: Toad Users Guide

146

Page 147: Toad Users Guide

Procedure Editor

The Procedure Editor, also called the Stored Procedure Edit/Compile window, letsyou create or modify procedures, functions, packages, triggers, types, and typebodies. It also has a PL/SQL debugging function and can show errors for objects if itencounters errors while compiling.

See the Debugging chapter (page 183) for more information about debugging.

By clicking the right mouse button or pressing F10 you access a context menu withnumerous options such as Set Bookmark, Uncomment Block, and Show EditToolbar.

3 ways to invoke the Procedure Editor window

� Click the third button on TOAD’s main toolbar.

� Select menu item Database > Stored Procedure Edit.

� Set the Procedure Editor to StartUp on new connection in the View > Options >Startup dialog.

The Procedure Edit window

Page 148: Toad Users Guide

148

Toolbar Buttons

Compile the current complete statement

Load a SQL file into the Procedure EditorThis button has a dropdown arrow that lists the most recent files used while this editor window wasopen.

Save the Procedure Editor contents to a new filename

Save the current editor contents to the file, only active if you’ve made changes to the script

Check file out of source control, lets you check files out of SourceSafe

Check file in to source control, lets you check files into SourceSafe

Load source from existing object in the databaseThis button includes a dropdown arrow and list to select from the most recent objects loaded fromthe database while this editor window was open. When the editor is closed, the list is reset.

The next 3 buttons only display when the Enable Compiling Multiple Objects From a Single Fileoption is checked in the Options dialog, Procedure Editor tab.

Execute FROM the cursor position to the end of the editor

Execute TO the cursor position from the beginning of the editor

Execute the highlighted statement

The Stored Procedure Edit/Compile toolbar

Page 149: Toad Users Guide

Chapter 7 Procedure Editor 149

Reload the object from database or file

Create a new Procedure, Function, Package, or Trigger

Compile Dependent procedures (objects that call this procedure)

SQL Lab/SQL Impact (includes dropdown that invokes SQL Lab (when installed) when QA reportis selected, and invokes SQL Impact (when installed) if Where Used is selected.Change active session for this windowThis button includes a dropdown arrow that lists the available sessions.

If you have the PL/SQL Debugger option, then these eight buttons display to the right of the Stored ProcedureEdit/Compile toolbar. Refer to the PL/SQL Debugger chapter (page 183) for more information.

Execute procedure using existing arguments

Set Parameters

Step Over

Trace Into

Trace Out

Halt

Add Watch

Compile Dependent Procedures with Debug information (procedures called by your procedure)

Page 150: Toad Users Guide

150

There is a second toolbar on the Procedure Edit window, parallel to the toolbar described above.The second toolbar is the standard TOAD editing/formatting toolbar, which is also used in the SQLEdit window. See page 37 for details. To turn on or off the common edit toolbar, right-click over theproc edit toolbar and select Show Edit Toolbar. There is also a TOAD Option, Editors tab, forShow Editor Toolbars.

In this window the Show Edit Toolbar option is checked, so the Edit Toolbar is displayed.

This is the same window with the Show Edit Toolbar option in the Right-Click Menu unchecked, so the EditToolbar is not displayed.

Page 151: Toad Users Guide

Chapter 7 Procedure Editor 151

Shortcut Keys

Shortcut Key Function

F1 Display Window Help File

F2 Show/Hide error panel

F3 Find Next Occurrence

F4 Describe Table, View, Procedure, Function, or Package in popup window

F7 Clear all text

F9 Compile

F10 Display Popup Menu

F12 Pass the SQL or Stored Procedure Editor contents to the specified External Editor

<CTRL>A Select all text

<CTRL>C Copy

<CTRL>D Display procedure arguments, for functions tells you the return datatype

<CTRL>F Find Text

<CTRL>G GoTo Line

<CTRL>L Convert Text to Lowercase

<CTRL>O Open a text file

<CTRL>R Find and Replace

<CTRL>S Save file

<SHIFT> <CTRL> S Save File As

<CTRL>T Display columns dropdown

<CTRL>U Convert text to Uppercase

<CTRL>V Paste

<CTRL>X Cut

<CTRL>Z Undo last change

<SHIFT><CTRL>Z Redo Last Undo

<CTRL><HOME> Go to col. 1, row 1 of the editor

<CTRL><END> Go to the last line of the buffer

Page 152: Toad Users Guide

152

<CTRL><SPACE> Display code template (key combination + <CTRL> <SPACE>) displays theapplicable template

<CTRL><TAB> Cycle through the collection of MDI Child windows

<CTRL><ENTER> Compile

<CTRL>. (period) Autocomplete tablenames

Page 153: Toad Users Guide

Chapter 7 Procedure Editor 153

Using the Procedure Editor

Navigating through the Procedure Edit window is similar to navigating through the SQL Editwindow.

Main ways to get code into the Procedure Editor

� Read from file

� Load from existing object from database

� Create new Procedure Editor dialog

� Type/Paste from scratch

� Drag and Drop from File Explorer

The F9 key compiles and then stores the code in the database.

Page 154: Toad Users Guide

154

To Open a Procedure Using File > Open

1 While in the Proc Edit window, Go to File > Open File.

2 The Select File for Edit window will display.

3 Double-click on the selected file.

4 The file is opened in the Procedure Editor.

To Load Source from an existing object

1 Click the Load Source from an existing object button.

2 The Select Database Object window will display.

3 Select the desired schema from the schema dropdown list.

4 You can filter using object types and a starts with, includes, excludes filter.

5 To preview the source for an object, select the object from the object list. Or, just double-clickan object name to load it directly into the Procedure Edit window.

6 Click the red right arrow.

Page 155: Toad Users Guide

Chapter 7 Procedure Editor 155

7 The selected object’s SQL script is displayed in the SQL script area of the Select DatabaseObject window.

8 Click OK.

The script is opened in the Procedure Editor and the Select Database Object window closesautomatically.

The filter button on the Select Database Object window shows and hides the four widgets forfiltering. If you hide the widgets, you have more area for the grid.

To Create an Object using the New Procedure button

1 Click the Create New Procedure toolbar button.

2 The New Procedure Create Options window displays.

Page 156: Toad Users Guide

156

3 Select an object type from the dropdown list.

4 Click in the Object Name textbox and type in an object name.

5 You can check or uncheck the Include or REPLACE option? checkbox. Checked produces“create or replace procedure procedure_name...” which WILL overwrite an existing procedurewith the same name. Unchecked produces “create procedure procedure_name...” which willNOT overwrite an existing procedure with the same name.

6 Click OK.

7 The template script with your object name is pulled into the Proc Editor.

The templates are NEWFUNC.SQL for Functions, NEWPACK.SQL for Packages,NEWPROC.SQL for Procedures, and NEWTRIG.SQL for Triggers. You can edit the templates tocreate a common starting point for new stored procedures. If you are creating a trigger, then theBEFORE/AFTER radio buttons and the INSERT/UPDATE/DELETE checkboxes become enabled.

The Create New Procedure buttondisplays the New Procedure dialogwhere you choose the object typefrom a drop down list and enter theobject name. It then loads a templatefrom the TEMPS folder.

Page 157: Toad Users Guide

Chapter 7 Procedure Editor 157

There is even an option to load the templates from the network if you elected to install TOAD to anetwork server share. See page 133 for details.

TOAD will automatically substitute values for keywords in the templates. TOAD will perform thefollowing substitutions.

� Object Name: %YourObjectName% or *YourObjectName*

� Sysdate: %SYSDATE%

� Date/Time: %DATETIME%

� Date: %DATE%

� Time: %TIME%

� Username: %USERNAME% (set in TOAD Options, Procedure Editor)

For example, this template:

/* Object Name: %YourObjectName% *//* Date: %DATE% */

is translated into:

/* Object Name: My_Proc_Name *//* Date: 5/15/2000 */

The Procedure Edit window is divided into two panels. The left panel contains the PackageNavigator List, a list of objects or package contents. Every package is composed of a Specification(SPEC) and Body, which is displayed in the hierarchy on the list. Functions in the list are indicatedwith an f( ) and Procedures in the list are indicated with a p( ).

The Package Navigator panel

Page 158: Toad Users Guide

158

The right panel is the Procedure Editor which lists the code for the selected object.

The multi-tabbed Procedure Editor panel

Page 159: Toad Users Guide

Chapter 7 Procedure Editor 159

The Error panel can only display one error at a time, so arrow buttons let you advance forward andbackward through the errors. The displayed error is highlighted in the procedure script in the display.

The Status panel shows the Row number and Column number of the cursor position, whether or notthe code has been modified, VALID or INVALID status, and whether or not the code was compiledsuccessfully or compiled with errors.

A vertical splitter between the package navigator list and the Procedure Editor lets you resize thenavigator list and the editor. A horizontal splitter between the Procedure Editor and the error panelcan be sized up or down.

The Procedure Edit window allows multiple statements per file, only if the TOAD Option, ProcedureEditor tab, Enable Compiling Multiple Objects From a Single File is checked. PackageSpecifications and Bodies can coexist in the same file.

The Error panel

The Status panel

Page 160: Toad Users Guide

160

You can run the selected procedure with the Execute button. For example if GIVE_RAISE is theselected procedure, if you press the Execute button it will run the GIVE_RAISE procedure.

If you select the Load Object from Database button you get a filter window. If your databasecontains many items, uncheck the option on the TOAD Options dialog, Proc Edit tab, Automaticallyshow objects on Select Database Object Window and set up filters before clicking the Executebutton. This will populate the list of existing objects much more efficiently.

Execute button

The red arrow lets you select objects from the left. Drop downs let you filter the lists.

Page 161: Toad Users Guide

Chapter 7 Procedure Editor 161

If you have the PL/SQL Debugger option and you click in the gutter of the ProcedureEditor, a breakpoint is created. So, when selecting text with the mouse, drag the selectorwithin the text area.

Page 162: Toad Users Guide

162

Navigator List

Navigator buttons

This button synchronizes the navigator list to the code. If you edit source in theeditor, this button will synchronize the list with your new edits.

Thimax

Thinav

Thior i

If thIf thalph

Thiyou

Synchronize navigator list to altered code

Shrink navigator list

s button shrinks the navigator list to a narrow empty band so that client space isimized. It also displays the Expand navigator list button.

s button displays after you shrink the navigator list. It lets you expand theigator list.

s button lets you sort the list of package functions and procedures alphabeticallyn the order they appear in the package.

e button is UP, the list appears in source code order.e button is DOWN (depressed) the SPEC and BODY lists are presentedabetically.

s button closes the navigator list. If you close the navigator and want to reopen it, need to right-click and select Show Navigator List.

Sort/Do not sort navigator list alphabetically

Here, the button is depressed so the SPEC and BODY lists are alphabetized.

Close navigator list

Expand navigator list

The right-click menu contains the Show NavigatorList item.

Page 163: Toad Users Guide

Chapter 7 Procedure Editor 163

Options for the Procedure Editor

The View > Options > Procedure Editor tab provides numerous options.

NOTE: The Editors tab contains options common to both the Procedure EditWindow and the SQL Edit Window.

Page 164: Toad Users Guide

164

Reload files when activating TOAD if the file time stamp is changed

Default – Unchecked

If checked, this allows editing in an external editor. When a Procedure Edit windowcontaining a file is reactivated (gets focus), TOAD will check the date stamp of thefile to see if it was modified by the external program. If the file was modified,TOAD will display a prompt dialog that will say that the file date/time has changedand ask you if you want to reload it. Select Yes, and the file will reload.

Highlight names of stored procedures

Default - Checked

This option refers to syntax highlighting, If checked, TOAD will highlight functionsand procedure names, in the Procedure Editor, SQL Editor, and the other read-onlyeditors in TOAD. For example, if PROC_B is a stored procedure, and you’vedesignated stored procedures to be displayed in red, “PROC_B” will display in red.NOTE: you must select a custom color in the Editor Options dialog, Highlightingtab, for User Procedures.

Include Owner When Extracting Source From Database

Default – Unchecked

If checked, this basically puts owner name in the command line. When exportingsource, if this option is checked, source will be prefixed with the owner.

Example:CREATE OR REPLACE PROCEDURE STHOMAS.PROCEDURENAME IS

If unchecked, source is not prefixed with the owner.

Hide the errors panel unless errors are raised following a compile

Default – Checked

If checked, the error panel is hidden until an error on compile occurs. If unchecked,the error panel is always displayed.

Page 165: Toad Users Guide

Chapter 7 Procedure Editor 165

Enable compiling multiple objects from a single file

Default – Unchecked

If checked, you can compile more than one object from a single source file. If notchecked, you are limited to one object per file, but you can still create separate MDIwindows for each object.

NOTE: this MUST be unchecked in order to use the PL/SQL Debugger, because thedebugger can handle only one object at a time per file.

Use 'Create' only when loading objects from the database

Default – Unchecked

If this option is checked, the Create Procedure will not overwrite an existing object.When loading PL/SQL into the Procedure Editor, the Create clause will read, "CreateProcedure/Function/Package ...". This is useful if when compiling a procedure, adifferent object of the same name already exists in the database, hence the compilewill fail, instead of overwriting it.

If unchecked, the Create clause will read “Create or Replace Procedure/FunctionPackage” and overwrite any existing objects that have the same name.

Automatically show all objects on Select Object from Database Window

Default – Unchecked

If checked, the Object Type filter is bypassed, and all objects from all object typesare displayed right away.

Search for Dependent Objects following a compile

Default – Checked

If checked, TOAD will search the database for dependent objects of the currentlycompiled PL/SQL object (those procedures that call this procedure), and if any arefound, will enable the Compile Dependencies button.

If unchecked, the Compile Dependencies button is never enabled.

Page 166: Toad Users Guide

166

If PROC_A calls PROC_B and you are editing and recompiling PROC_B, Oracleflags PROC_A as INVALID, forcing a need to recompile PROC_A. TOAD willcheck for this dependency, enable the Compile Dependencies button, which you canthen click to compile PROC_A, and therefore not leave any INVALID objects outthere as a result of your changing PROC_B.

User Name for New Procedure Templates %USERNAME% textbox

Default - Blank

The value you enter in the box will be substituted automatically for%USERNAME% when new procedure templates are read up into the StoredProcedure Editor.

Show Package Navigator Panel

Default – Checked

If checked, displays the Package Navigator hierarchy of package procedures andfunctions in the panel that is to the left of the Stored Procedure Editor. This lets youclick the procedure names in the navigator to advance the editor to that section ofsource.

Sort Package Navigator Panel

Default – Checked

If checked, this option displays the package procedures and functions in alphabeticalorder. If unchecked, it displays them in original package order.

Notification when compile process is complete

Default – Unchecked

When checked, this plays the TOADLOAD.WAV (croak sound) when the compileof a procedure has completed.

Page 167: Toad Users Guide

Chapter 7 Procedure Editor 167

Only show one Procedure Editor per database connection

Default – Unchecked

If checked, permits only one Procedure Edit window per database connection, toconserve windows resources.

This is similar to the option that limits the number of SQL Edit windows and SchemaBrowser windows, per connection.

Page 168: Toad Users Guide

168

Right-Click Menu

Click the right mouse button while you are in the Procedure Editor to access theRight-Click Menu. This provides a shortcut to the functions listed in the menu.

You can also press F10 to display the Right-Click Menu.

Many of these items are the same as the items found in the SQL Edit window Right-Click Menu. Some of the functions that the menu contains are:

DescribeDisplays popup window that describes the selected object. If the item is aprocedure it displays the procedure popup window.

Search Knowledge BaseIf you’ve installed RevealNet’s Knowledge Base, you can easily access andsearch the Knowledge Base through the Right-Click Menu.

Close File/TabCloses the current File/Tab

New File/TabAdds another tab and places the cursor on line 1 of your new script

Comment BlockAdds dashes before the line

Format StatementFormats your SQL statements using RevealNet’s PL/Formatter product ifinstalled or just a basic format if PL/Formatter is not installed.

Find Closing BlockFinds closing parenthesis, "END" for matching "BEGIN" or "END IF" formatching "IF”

Show Navigator ListShows/hides the navigator panel

Page 169: Toad Users Guide

Chapter 7 Procedure Editor 169

Source Code Management

When activated on the Options window, TOAD supports a simple interface toMicrosoft's Visual SourceSafe (VSS) source management application. The toolbaron the Procedure Editor has buttons for checking in and checking out source files. Inaddition, a browser style interface to VSS is available from the View menu. Thiswindow provides check in, check out, and uncheck out capabilities.

In order to use the VSS interface, you must have the VSS 5.0 or later client installed.If you installed the VSS client as another internal interface, such as the one thatcomes with VB 5.0, and you have only accessed the VSS database through the VBinterface, TOAD will not find the database. You must access the VSS databasethrough the main VSS program (SSEXP.EXE) in order for TOAD to locate the VSSdatabases.

The interface to VSS is configured on the TOAD Options window, Source Controltab.

To set the interface to VSS on the Options window1 Select VSS as your source management system.

2 Pick a default VSS database from the list.

3 Provide a login name for the VSS login prompt.

If none of these options are enabled, TOAD did not find the following registrysetting:

HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\SOURCESAFE\SCCSERVERPATH

This path specifies the location of the SSSCC.DLL file and is required to interfacewith VSS.

Note: The client portion of the VSS install must be run. You cannot run only theserver piece of the VSS install.

To check out a file1 Go to the Stored Procedure Editor window.

Page 170: Toad Users Guide

170

2 Click the Check File Out of Source Control toolbar button.

If you have not logged into VSS recently...The VSS Login window displays.Enter your VSS username and password.Select the desired VSS database.Click OK to proceed.

3 The TOAD VSS Interface window displays.

4 Drill down to the project.

5 Select a file to check out.

6 Click the Check Out button.

7 TOAD will check the file out of SourceSafe, place it into the working folder,and load the contents of the file into the Procedure Editor window.

Then make your changes, compile it to the database, etc.

To check in a file1 Save the editor contents back to the checked out file in the working folder (click

the Save File floppy disk icon button in the toolbarORSelect File > Save from the menuORPress <CTRL>S).

If you do not save the changes back to the file, TOAD will check the unchangedfile back into SourceSafe. TOAD does NOT check in the editor contents, it onlychecks in saved files.

2 Click the Check File In To Source Control button on the toolbar.

3 The TOAD VSS Interface window displays.

4 Drill down to the appropriate project.

5 Select the checked out file.

6 Click the Check In button to check the file back into SourceSafe. Alternatively,you could click the Undo Check Out File button to undo the check out and notsave your changes.

7 Click the Cancel button to close the TOAD VSS Interface window.

Page 171: Toad Users Guide

Chapter 7 Procedure Editor 171

Procedure Editor Tasks

This section demonstrates how to create a few simple functions using the ProcedureEditor (converting temperatures from Fahrenheit to Celsius and from Celsius toFahrenheit). It also shows how to use edit/replace with the functions, how to test thefunctions using the set parameters and execute buttons, how to grant publicprivileges, and finally how to create public synonyms.

SI

The Conversion Formulas

Celsius = (Fahrenheit-32) * 5/9Fahrenheit = (Celsius * 9/5) + 32

tored procedures are useful for processes that will be repeated over an over again.n this example, the procedures are the temperature conversion functions.

Page 172: Toad Users Guide

172

F_TO_CELSIUS

First you need to create a new stored procedure function that will convert Fahrenheitto Celsius.

To Create a New Procedure1 Click the Create a new procedure button.

2 The New Procedure Create Options dialog window displays.

3 From the Object Type dropdown menu select function.

4 Type in the function name “F_TO_CELSIUS”.

5 Click OK.

Create a new procedure

Page 173: Toad Users Guide

Chapter 7 Procedure Editor 173

6 A template script displays with F_TO_CELSIUS in the Create or Replace line.

(Now you need to edit the script with the input and return arguments.)

7 After F_TO_CELSIUS on the first line type the following:(IN_FAHRENHEIT NUMBER)

8 After RETURN NUMBER IS type the following:OUT_CELSIUS NUMBER

Your script should now look like this.

9 Scroll past the comment section and after the BEGIN statement edit the next line(it contains a tmpvar holder) to match the following formula.OUT_CELSIUS := (5/9) * (IN_FAHRENHEIT – 32);

10 after RETURN typeOUT_CELSIUS

Notice the END statement has been automatically filled in.

END F_TO_CELSIUS;

The final script should look similar to this. Here, all extra comments and spaces havebeen deleted.

Compile button

This script converts Fahrenheit to Celsius.

Page 174: Toad Users Guide

174

You can compile the script for a quick syntax check. If you get errors they’ll displayin the error panel, and you can correct and recompile.

C_TO_FAHRENHEITNow you can go to Edit > Select All and then Edit > Copy, copy the code you’vejust created, and paste it into a new tab in the Procedure Editor. (See the Right-ClickMenu, option New File/Tab.) Then use the Edit/Replace function to change thecopy of the Fahrenheit to Celsius script to a Celsius to Fahrenheit script.

To Use Edit/Replace1 Place the cursor on the text you want to replace, in this case F_TO_CELSIUS.

2 Type <CTRL>R or choose the Edit > Replace menu item.

3 The Find and Replace dialog displays with the selected item already in the Textto Find entry.

4 Type in what you want to replace the text with, in the caseC_TO_FAHRENHEIT.

5 Click the Replace All button to replace all occurrences of the text.

6 Press ESC to close the dialog window.

7 Select your next replacement item, which in this case would beIN_FAHRENHEIT.

8 Press <CTRL>R to open the Find and Replace dialog.

9 The selection is already entered. Type in IN_CELSIUS for the replacement.

Page 175: Toad Users Guide

Chapter 7 Procedure Editor 175

10 Select the Replace All button.

11 Repeat the Find/Replace or manually edit to change the followingOUT_CELSIUS to OUT_FAHRENHEIT5/9 to 9/5– 32 to + 32(You'll need to manually edit line 5 so that the formula is in the correct order.)

The final script should look like the following.

Page 176: Toad Users Guide

176

Now, using the just created Celsius to Fahrenheit script, you can test the function.

To input and output values

1 Click the Set Parameter button.

2 An Execute Procedure dialog displays with your argument filled in.

3 Type in a value in the value cell, such as 22.

4 The value is automatically entered in the SQL Code panel.

5 Check the Output OUT args checkbox. This sets up anonymous PL/SQL blockto test the function and uses the DBMS_OUTPUT package to get an output.

Set Parameter button

Page 177: Toad Users Guide

Chapter 7 Procedure Editor 177

6 Click OK. The dialog closes.

7 Click the Execute button.

8 The value displays in a DBMS_OUTPUT dialog box.

You can also test the functions in a SQL Edit window, but the Procedure Editorprovides a shortcut to typing in your own anonymous PL/SQL block.

Page 178: Toad Users Guide

178

You can also grant public privileges for your procedures. So, anyone on yourdatabase can use your stored procedure function. This involves the Schema Browser,which is discussed in detail in the Schema Browser chapter.

To Grant Public Privileges1 Select the Schema Browser button.

2 The Schema Browser window displays.

3 On the left panel, select the Procs (Procedures) tab.

4 Expand the functions list.

5 Select the C_TO_FAHRENHEIT function. Details for the selected functiondisplay in the right panel.

6 Click the Privileges button.

7 The Privileges window displays. The list is organized by user schemas, thenPUBLIC, then individual roles.

Schema Browser button

Privileges button

Page 179: Toad Users Guide

Chapter 7 Procedure Editor 179

8 Select PUBLIC from the list.

9 Check the EXECUTE checkbox, which gives Execute privileges.

10 Click the Apply button.

11 A dialog will display telling you the changes to the privileges have been applied.

You can now close the Privileges window and repeat these steps for theF_TO_CELSIUS function.

While you are still in the Schema Browser window, you can click the Grants tab andsee the privileges that have been granted from your procedure to other users or roles.

Page 180: Toad Users Guide

180

You might want to create a public synonym for your procedure.

To Create A Public Synonym

1 From the main menu select Create > Synonym.

2 From the dropdown menu select the object type. For our C_TO_FAHRENHEITand F_TO_CELSIUS examples, the object type would be Function. This acts asa filter when you click the Find button. Nothing will appear in the list until youclick the Find button.

3 If you want to filter even further, you can type the first letter or letters of yourobject in the Like% box. (Like% is the standard SQL command).

4 Then Click the Find button.

5 The filtered object(s) display in the list.

Here, the %TO filter displayed all objects that contained TO. TOAD automatically added% to the end (Like%), so %TO became a %TO% filter. Then both C_TO_FAHRENHEITand F_TO_CELSIUS were selected by pressing the <CTRL> key while clicking on theobjects.

6 Double-click on a single object to move it to the lower panel. Or you canmulti-select several times, and drag and drop them to the lower panel.

Page 181: Toad Users Guide

Chapter 7 Procedure Editor 181

7 Checkboxes let you choose whether or not you want to include a drop statementand whether or not you want to make this a public synonym. (In this example,we want a public synonym.) You could also rename the synonym by selecting itin the bottom list (click, pause, click) and typing in a new name.

8 Click the green arrow to execute the synonym script.

9 A message window will confirm the synonym has been created.

Now that you’ve granted public privileges and even included public synonyms,anyone in a different schema can easily access your C_TO_FAHRENHEIT andF_TO_CELSIUS stored procedure functions.

While in the SQL Editor, after typing the procedure name you can press F4 todisplay a function popup describe window that shows details including the type ofargument it is, the code for the argument, and the grants. You could select and copythe code into your own script.

Procedure Argument Display

Typing the procedure name and <CTRL>D would pull in a line of code that includesthe IN and OUT arguments, which, for this example, is the IN_CELSIUS statement.It will still need to be edited, but parts of the code are already filled in for you. In thecase of functions, it includes the datatypes, return types, etc.

Page 182: Toad Users Guide

182

Package List/Procedure Argument Display Combination

When you’re in either a Procedure Edit window or a SQL Edit window, you can typethe package name and a period and a popup list displays a list of functions andprocedures in that package. After you select the package function or procedure,<CTRL> D looks up the argument. This is basically two shortcuts for two steps.

Using SourceSafe

It’s always a good idea to save your code into SourceSafe. Refer to the Source CodeManagement section of this chapter (page 169) for more information aboutSourceSafe.

Page 183: Toad Users Guide

PL/SQL DEBUGGER

The PL/SQL Debugger is an optional feature for TOAD. The PL/SQL Debugger,which is run in the Procedure Editor window, lets you step through the code as itexecutes, line-by-line, statement-by-statement. The Debug menu is only enabled in aProcedure Edit window. You can run a debug session with or without argumentvalues. With the click of the toolbar button, debugging begins and stops onbreakpoints as appropriate or it runs to the end.

If you have the Debugger installed, the Debug toolbar (8 buttons) displays to theright of the Stored Procedure Edit/Compile toolbar in the Procedure Edit window.You can also access the Debug menu using the keyboard by pressing <ALT>U.

Unless you specify parameter values in the Execute Procedure dialog, they willdefault to NULL values. So, for functions that depend on the argument values, youcan still check the branching, logic, etc. You can also set argument values in theExecute Procedure dialog, and it will use those values.

You can add, edit, and delete breakpoints. You can also set conditional breakpoints.

After the procedure has executed, you can view the DBMS_OUTPUT from theserver.

Page 184: Toad Users Guide

184

Dependencies

You can use the Debugger to check for dependencies.

If procedure A calls procedure B, and you are editing and debugging procedure B,and then you click F9 to compile procedure B, procedure A is marked invalid (theOracle dictionary gives procedure A an invalid status. This is not visually indicated,but when you try to execute procedure A, it won’t execute, it’ll be rejected).

So, TOAD’s solution to this is the Check dependencies following a compile optionbutton. This refers to checking for upper dependencies.

What is an upper dependency? If procedure A calls procedure B, and you are editingprocedure B, procedure A is the upper dependency.

If the Options > Procedure Editor > Search for dependent objects following acompile is checked, TOAD runs an additional query to see if any procedures call thecurrent procedure. So, if the query includes dependencies (procedures that call yourprocedure) the Compile Dependencies button is enabled. Notice the symbol on thisbutton is a combination of the right arrow which is used in TOAD as a compilesymbol, and a symbol that represents a hierarchy of procedures.

When you click the Compile Dependencies button, TOAD will recompile allprocedures that call your procedure. The button then becomes disabled. If you makeany additional edits and compile the procedure, the button is enabled again.

If you want to visually view dependencies and which dependencies are invalid, youcan go to the Schema Browser and click the Procedure tab, then the Deps(uses) andDeps (used by) tabs. This visually shows anything that has an invalid status with ared X over the object. The Schema Browser is discussed in detail in the SchemaBrowser chapter (page 231).

Compile Dependencies

Page 185: Toad Users Guide

Chapter 8 PL/SQL Debugger 185

Requirements

Minimum Oracle Database Requirements

For all databases, you must have the Oracle Probe API installed in order to debugPL/SQL using TOAD. Check for the existence of a package named DBMS_DEBUGin the SYS schema. Also check for grant execute to public, to roles, or to users.

Here’s how to check what Probe version you have:

Run this anonymous PL/SQL block in the SQL Editor with a DBMS Output windowopen to find out what version of the Probe API you have:

declare

probe_major_ver varchar2(10);

probe_minor_ver varchar2(10);

begin

dbms_debug.probe_version(probe_major_ver, probe_minor_ver);

dbms_output.put_line('MAJOR='||probe_major_ver);

dbms_output.put_line('MINOR='||probe_minor_ver);

end;

If the DBMS Output window displays:

MAJOR=2

MINOR=3

Then the version of Oracle Probe API is 2.3.

Page 186: Toad Users Guide

186

Here are some notes about using the PL/SQL Debugger on different Oracle databaseversions.

Database Version Notes

Oracle 7.3.4 on Unix,Oracle 7.3.4 on NT

Inspect package variables by stepping into the packagefirst, then add the watch on the package variable.

For the Call Stack to display, you must set theBLANK_TRIMMING value to TRUE in the init.oraOracle Initialization parameters file and restart yourdatabase. Otherwise, the Call Stack menu will bedisabled. Refer to your Oracle documentation regardingthe effects of the BLANK_TRIMMING setting.

On Oracle 7 databases, if you receive “Debugger is notresponding” message, comment out all DBMS_OUTPUTstatements and then recompile, and use watches to displaythe values. Also uncheck Enable DBMS Output beforeevery debugging session.

Oracle 8 BLANK_TRIMMING requirement also refers todatabases 8.0.4 and 8.0.5.The PL/SQL Debugger works fine on Oracle 8 databases.

Oracle 8i No notes or issues.The PL/SQL Debugger works fine on Oracle 8i databases.

ADDITIONAL NOTES:

� You cannot use the Eval/Modify window to change argument values.

� Custom data types (like Oracle 8 objects and records) are supported by thedebugger, but the Execute Procedure dialog might not be able to generate a validblock when these types are used. You can manually edit the block to correctlydeclare and initialize these types for their use in the debug session. The onlydatatypes fully supported in arguments are scaler datatypes (such as number,character, date).

Page 187: Toad Users Guide

Chapter 8 PL/SQL Debugger 187

� Procedures must be in the package spec in order to be debugged.

� Lengthy server delays (such as when you open large cursors or have a slowdatabase connection) might cause a timeout that results in the “Debugger is notresponding) message. You can increase the timeout period in the options screento correct this problem.

� Watches on package variables are only allowed for Probe v2.2 or higher.

Page 188: Toad Users Guide

188

To run the PL/SQL Debugger

To run the PL/SQL Debugger, you must have a Quest Software license key withthe PL/SQL Debugger option activated in the key. You can verify that theDebugger option is activated by checking the TOAD Help > About menu andsee what options are listed.

If you have just purchased the Debugger, you need to install your new licensekey also known as the registration key. The PL/SQL Debugger option isactivated in the license key.

To Activate the PL/SQL Debugger Registration Key1 Start TOAD.

2 Go to Help > Register TOAD.

3 The Product Authorization window displays.

4 Click in the Enter Authorization Key textbox and enter the registration key.

5 Click OK.

Open a new Procedure Edit window. The items on the Debug menu should now beenabled.

Page 189: Toad Users Guide

Chapter 8 PL/SQL Debugger 189

Debug Toolbar buttons

The Debug toolbar is contained on the right half of the Stored ProcedureEdit/Compile toolbar. It looks like this.

Execute procedure using existing arguments

Set Parameters

Step Over

Trace Into

Trace Out

Halt

Add Watch

Compile Dependent Procedures with Debug information (procedures called byyour procedure)

Page 190: Toad Users Guide

190

If the Enable compiling multiple objects from a single file option is checked, thedebug buttons (Execute, Set Parameters, Step Over, Trace Into, Trace Out, Halt, andAdd Watch) are disabled on the right side of the toolbar.

You must have the Enable compiling multiple objects from a single file optionunchecked on the TOAD View > Options > Procedure Editor tab in order to usethe Debugger. (If the option is turned on (checked), and you attempt to debugmultiple objects, TOAD automatically unchecks the option and begins to debug as ifthere were a single object in the file. A warning message box also displays.) Youcannot debug a file containing multiple PL/SQL objects. There has to be one-to-onecorrespondence from the lines of source in the editor to the lines of source in thedatabase.

Objects you can Debug

� Top-level Functions

� Top-level Procedures

� Package Functions

� Package Procedures

� Triggers

Objects you cannot debug

� Java classes

� Oracle 8 object methods

� Anonymous PL/SQL blocks

Page 191: Toad Users Guide

Chapter 8 PL/SQL Debugger 191

The Debug menu is enabled if you have the Debugger installed and you are in theProcedure Edit window. The Debug menu is disabled for all other TOAD windows.

You can also access a smaller Debug menu in the Procedure Edit window.Right-click over the editor, select Debug from the menu, and several Debugfunctions will appear on the submenu.

Right-click Debug menu

The Debug menu in the Procedure Editor window

Page 192: Toad Users Guide

192

D s

ebug Function Function Description

Execute Current Source Starts debugging and runs to the next breakpoint or end of procedure with thecurrent argument settings (set using Set Parameters).

Set Parameters Displays a dialog to set the IN or IN/OUT argument values, and, in the case ofa Package, lets you select which package procedure or package function todebug.

Run (ContinueExecution)

Once you are stepping through the code, this function runs to the end of theprocedure or to the next breakpoint, whichever it encounters first.

Run to Cursor Once debugging has begun, it runs to the cursor location as if it were abreakpoint, and stops.

Step Over Executes one line of code at a time, bypassing a procedure or function call.

Trace Into Executes one line of code at a time, stepping into other procedures as they arecalled.

NOTE: Only the top-level procedure will have debugging informationavailable for it. If you step into another procedure and want to viewdebugging information, click the Compile dependencies with debug button,(located on the end of the second row of buttons). Otherwise the message “nodebug information available” will appear in the Watch window.

Trace Out Executes to the bottom of the called procedure, returning to the caller tocontinue debugging the caller, stopping on the line following the call.

Halt Execution Ends Debugging. Stops “stepping” through the code, retaining watch andbreakpoint settings.

Add a Breakpoint atCursor

Adds or removes a breakpoint at the cursor location.

Evaluate/Modify Displays a window where you can (on the fly) inspect and/or change values ofvariables and continue execution with the new values.

Breakpoints Displays a dockable window of the currently set breakpoints, allowing you toadd, edit, delete, enable, or disable breakpoints.

Call Stack Displays a dockable window of the current procedure or function call stack(which procedures called which other procedures). This list is meaningfulonly during execution, as indicated by the “Running” light in the status panel.

Page 193: Toad Users Guide

Chapter 8 PL/SQL Debugger 193

The Call Stack window is blank when you are at “Idle.”

Also see the Requirements section in this chapter, page 185, for enabling theCall Stack window.

Watches Displays a dockable window of the current variables being watched, allowingyou to add, edit, delete, enable, or disable watches.

Add Watch at Cursor Adds a Watch at the cursor position.

DBMS_OUTPUT Displays a dockable window for displaying DBMS_OUTPUT generated fromthe procedure code.

NOTE: The DBMS_OUTPUT content is not released from the database (andtherefore not displayed) until all procedures have finished, or you force it tostop via the Halt button or Halt Execution menu item.

Page 194: Toad Users Guide

194

Debug Shortcut Keys

Keyboard Shortcut Function

F5 Set or Delete a Breakpoint on the current line

<CTRL>F5 Add Watch at Cursor

F7 Trace Into

F8 Step Over

<SHIFT>F8 Trace Out

F9 Compile without Debug information

<SHIFT>F9 Execute Current Source

<CTRL>F9 Set Parameters

F10 Display right-click popup menu

F11 Run (continue execution)

F12 Run to Cursor

<CTRL><ALT>B Display Breakpoints

<CTRL><ALT>D Display DBMS_OUTPUT

<CTRL><ALT>E Evaluate/Modify

<CTRL><ALT>S Display Call Stack

<CTRL><ALT>W Display Watches

Page 195: Toad Users Guide

Chapter 8 PL/SQL Debugger 195

Using the Debugger

NOTE: “Procedure” refers to PL/SQL code including procedures, functions, packageprocedures, package functions, or triggers.

To start the Debugger

1 Open the DatabaseORClick the

2 Load a PLYou canLoad a prORLoad a prORType a prORClick the

3 Compile tPressing FORClicking t

4 Press F7 (symbol ta

If you want toclick the Comdebug process

T

Com

he Open a New Procedure Edit window buttonis located on the main TOAD toolbar.

Stored Procedure Edit/Compile window from either the > Stored Procedure Edit menu item

Open a New Procedure Edit window button on the main toolbar.

/SQL procedure into the editor or write a new procedure.

ocedure from a file on disk

ocedure from an existing object in the database

ocedure from scratch

New Procedure button.

he procedure by9

he Compile button on the Stored Procedure Editor toolbar.

Trace Into) to start stepping through the code. TOAD generates theble required to obtain debug information for this procedure.

step into other procedures and view debug information you’ll need topile Dependencies with Debug toolbar button before beginning the.

pile button

Page 196: Toad Users Guide

196

You can set TOAD to

� Always compile dependent procedures

� Never compile dependent procedures

� Be prompted whether or not to compile dependent procedures

To set any of these options go to View > Options > Debugging tab.

Otherwise, watched variable values in the dependent procedures will have “no debuginformation” displayed in the watches window.

To finish running the Debugger

Click the Continue execution to breakpoint button on the toolbarORSelect Run (continue execution) from the Debug menu.

To stop the Debugger

1 Click the Halt toolbar buttonORClick the Debug > Halt Execution menu item.

2 The status resets from Running to Idle.

When you finish debugging your PL/SQL code, compile it once again by pressingF9 to discard the symbol table.

Halt

Page 197: Toad Users Guide

Chapter 8 PL/SQL Debugger 197

The Status Panel Indicators

When debugging PL/SQL code, the word “Running” displays in a segment of theStored Procedure Edit/Compile window status panel at the bottom of the window.

If you are not debugging a procedure, “Idle” displays.

Page 198: Toad Users Guide

198

Options menu for Debugging

View > Options > Debugging tab displays this menu of Debugging settings.

Page 199: Toad Users Guide

Chapter 8 PL/SQL Debugger 199

ColorsTo set the colors of a breakpoint, current execution point, or any disabled breakpoint

1 Select the item type (breakpoint, current execution point, or disabled breakpoint)from the list at the left.

2 Move the mouse pointer over the color selectors.

3 Click the left mouse button to select a foreground color (e.g., the code textcolor). The letters FG appear on the palette on your selected foreground color.

4 Click the right mouse button to select a background color. The letters BG appearon the palette on your selected background color.

Allow watches on package variables

Default – Checked

This checkbox is provided because the Oracle Probe API call for watching packagevariables acts differently on Oracle 7 and Oracle 8 databases. On Oracle 7 databases,you have to step into the procedure BEFORE adding a watch on a package variable.On Oracle 8, you can set up the watch on the package variable before or afterstepping into the procedure. If you do not want to inspect package variables, thenuncheck this option.

Automatically show all debugging windows when debugging

Default – Checked

When checked, this will bring up the docked window with all 4 windows:Breakpoints, Watches, Call Stack, and DBMS_OUTPUT if any of the four areopened. With this option unchecked, each window is activated separately, undocked.

Page 200: Toad Users Guide

200

Default Debugging Windows to StayOnTop

Default – Checked

When checked, this will create the Breakpoints, Watches, Call Stack, orDBMS_OUTPUT window as a Stay-On-Top window when activated. Otherwise,they will be hidden underneath TOAD whenever the Stored Procedure Editorwindow gets focus.

Enable Trace Output while debugging

Default – Unchecked

This checkbox creates trace information while the Debugger is running, which willhelp debug the Debugger interactions with the database. This is normally uncheckedand is used for technical support or DBA. The trace files are written to the databaseserver, folder specified by the USER_DUMP_DEST Oracle database initializationparameter.

Enable DBMS_OUTPUT before every debugging session

Default – Checked

If this box is checked, after you run a procedure that contains DBMS_OUTPUTstatements, the DBMS_OUTPUT window will display automatically.

Break on exceptions

Default – Checked

A check in this checkbox causes the Debugger to stop when it hits a procedureexception (such as zero divide) and display a message. You can then continuedebugging the exception handler code or stop.

Break on exceptions will cause TOAD to display a message like this whenever it hits an exception.

Page 201: Toad Users Guide

Chapter 8 PL/SQL Debugger 201

Debug session timeout (in seconds) textbox

Default – 10 seconds

This option limits the amount of time that the Debugger will wait for the database torespond with debug information. You can enter the number of seconds.

For a slow database, poor network speeds, or connection via modem, increase thenumber of seconds.

Date format for watches

Default – DD-MON-YY

This dropdown menu lets you select a date format.

DD-MON-YYMM/DD/YYMM/DD/YYYY – which displays all 4 digits in the year

NOTE: Date format does not affect the NLS_DATE_FORMAT for the TOADsessions/connections, it only affects the debugger session.

Compile Dependencies Yes/No/Prompt

Default – No

This will conditionally compile procedures called by your procedure with debuginformation just before debugging begins.

All the Option settings are saved in TOAD.INI and restored the next time TOAD isinvoked.

Page 202: Toad Users Guide

202

The Dockable Windows

There are 4 stay-on-top windows in the Debug menu: Breakpoints, Call Stack,Watches, and DBMS_OUTPUT.

Any of these 4 windows can be docked together into one window (or combinationsof multiple docked windows) by dragging the window title bar of one window anddropping it on another window. This creates a tabbed interface to the separate panels.

To see how this works, select Debug > Breakpoints from the main toolbar. Noticethat the Breakpoints window displays over other tabs (the DBMS_OUTPUT tab andthe Watches tab). If the Call Stack information is available, see the Requirementstopic on page 185 to adjust your settings accordingly, then the Call Stack windowwill also display.

Click a tab to display its corresponding window. You can also click and drag the tabsto move the windows. You can display all the windows at once. To return thewindows to their docked as one position, simply drag them by their tabs and placethem on top of each other.

The Breakpoints window is part of a group of windows (Breakpoints, Watches, DBMS_OUTPUT, and CallStack) that are docked together into one window. Click and drag the tabs to separate them. They can all bedisplayed at the same time.

Page 203: Toad Users Guide

Chapter 8 PL/SQL Debugger 203

An option in TOAD Options (View > Options > Debugging item) causes all 4debug windows to open when any one debug window is opened. To activate thisoption check the Automatically show all debugging windows when debuggingitem.

Page 204: Toad Users Guide

204

BreakpointsA breakpoint is a line in a program that you designate as a place where execution bythe Debugger will stop. When the Debugger reaches a line with a breakpoint, it stopsexecution prior to executing any code that was on that line.

Breakpoints Right-Click Menu

When you are in the Breakpoints window, you can right-click to access a menu forbreakpoints. If you right-click while a breakpoint in the list is selected, or you right-click on a breakpoint in the list, additional items are enabled in the menu that applyto that specific breakpoint. You’ll find this method provides a shortcut whenperforming various breakpoint functions.

The Breakpoints Right-Click Menu

Page 205: Toad Users Guide

Chapter 8 PL/SQL Debugger 205

To set or reset breakpoints

You should set your gutter width to 35.See the Edit > Editor Options dialog to change the gutter width.

1 Different ways to perform this step

� Click in the Procedure Editor gutter.

� Press F5.

� Select Debug > Add Breakpoint at Cursor.

� From the Breakpoints menu (Debug > Breakpoints), right-click and selectthe Add Breakpoint menu item listed in the Right-Click Menu.

� From the Breakpoints menu (Debug > Breakpoints), press <CTRL>A.

� Press <INSERT> to add a breakpoint. Press <DELETE> to delete abreakpoint.

2 A stop sign displays in the gutter, and the whole line is highlighted in defaultred, or whatever color you selected from the View > Options > Debuggingmenu.

Stop signs in the gutter and red highlighted lines indicate the breakpoints.

Page 206: Toad Users Guide

206

To edit a breakpoint

1 Different ways to perform this step

� Double-click the breakpoint in the Debug > Breakpoints window.

� Single-click the breakpoint in the Debug > Breakpoints window and right-click to display the Right-Click Menu, Select the Edit Breakpoint menuitem.

� While in the Debug > Breakpoints window, click on a breakpoint from thelist and press <CTRL>E.

2 The Breakpoint Properties dialog displays.

3 Edit the information.

4 Click OK.

The Breakpoint Properties dialog window

Page 207: Toad Users Guide

Chapter 8 PL/SQL Debugger 207

Conditional Breakpoints

A conditional breakpoint only breaks if a certain condition is met.

To set conditional breakpoints

1 Select Debug > Breakpoints.

2 The Breakpoints window displays.

3 Pull up the Breakpoint Properties Dialog window via Right-Click Menu,double-click on the breakpointORPress <CTRL>E.

4 Enter the condition for the breakpoint in the Condition textbox, e.g.“Salary_In>5000.

The format for Conditio

<= Less than or e<> Does not equa>= Greater than o< Less than> Greater than= Equal

T

he Breakpoints Properties window

n is: variable operator value. Supported operators are:

qual tolr equal to

Page 208: Toad Users Guide

208

5 Click OK.

When you run the Debugger, it will stop on the breakpoint only if the condition ismet.

Pass Count Breakpoints

You can also set breakpoints that break ONLY after a certain number of passes in aloop have occurred. These are known as pass count breakpoints.

To set a pass count breakpoint

1 Select Debug > Breakpoints.

2 The Breakpoints window displays.

3 Pull up the Breakpoint Properties Dialog window via Right-Click Menu,double-click on the breakpointORPress <CTRL>E.

4 Enter the pass count number in the pass count textbox. This is the number ofpasses in a loop that will occur before the Debugger will stop on the breakpoint.The pass can be a FOR loop, DO WHILE loop, IF/END IF, etc.

5 Click OK.

Page 209: Toad Users Guide

Chapter 8 PL/SQL Debugger 209

Conditional Pass Count Breakpoints

You can specify both a condition and a pass count. Then the break will occur afterthe nth (n = pass count number) time the condition is met.

Enabling or Disabling a Breakpoint

Once you set a breakpoint you can temporarily disable it and then later enable itagain.

To enable or disable a breakpoint

1 Select Debug > Breakpoints.

2 The Breakpoints window displays.

3 Pull up the Breakpoint Properties Dialog window via Right-Click Menu,double-click on the breakpointORPress <CTRL>E.

4 Uncheck the Enabled checkbox to disable the selected breakpoint.ORCheck the Enabled checkbox to enable the selected breakpoint.

5 Click OK.

Disabled breakpoints will be grayed out in the Breakpoints window.

Page 210: Toad Users Guide

210

WatchesA watch lets you designate a variable to be evaluated. A watched variable’s valuecan only be displayed during procedure execution.

Watches Right-Click Menu

While in the Watches window, right-click to access the Right-Click Menu list ofwatch specific commands.

The Watches Right-Click Menu

Page 211: Toad Users Guide

Chapter 8 PL/SQL Debugger 211

To add a watch

Different ways to add a Watch

� Double-click to select a variable in the editor.Click the Add Watch button in the toolbar and the variable will be added to thelist of watches.

� From the editor, click the right mouse button.The Right-Click Menu displays.Select the Debug > Add Watch at Cursor menu item, or <CTRL>F5.

� From the Watches window, click the right mouse button.The Right-Click Menu displays.Select the Add Watch menu item.

� From the Watches window, Press <CTRL>A to bring up the add watchesdialog window.

� From the Watches window, press <INSERT> to add a watch and <DELETE>to delete a watch.

NOTE:

� You cannot watch a trigger :new.column or :old.column value. The OracleProbe API does not support it.

� It is recommended that users do not explicitly declare implicitly definedvariables, because the implicit variable will be created anyway. So, the usercan just inspect the implicit variable directly.

Because of limitations in the Oracle Probe API, you cannot watch implicitly definedvariables when they are also declared explicitly in the variables declaration section.For example, the following code is correct, but you cannot watch the Counter_Varvariable as it loops. A workaround to this would be to explicitly declare a localvariable, e.g., Counter_Var_Watched, and copy the contents as it is changed, thenadd the watch to the local variable, Counter_Var_Watched.

Add Watch

Page 212: Toad Users Guide

212

From this:

CREATE OR REPLACE FUNCTION F_Calc_Bonus (Salary_In IN NUMBER)

RETURN NUMBER IS

Counter_Var NUMBER;

Bonus_Out NUMBER;

BEGIN

/* Set Bonus earned equal to 10 percent of the employee's salary. */

FOR Counter_Var IN 1..5 LOOP

Bonus_Out := Salary_In * 0.10;

END LOOP;

RETURN Bonus_Out;

END F_Calc_Bonus;

/

To this:

CREATE OR REPLACE FUNCTION F_Calc_Bonus (Salary_In IN NUMBER)

RETURN NUMBER IS

Counter_Var NUMBER;

Counter_Var_Watched NUMBER;

Bonus_Out NUMBER;

BEGIN

/* Set Bonus earned equal to 10 percent of the employee's salary. */

FOR Counter_Var IN 1..5 LOOP

Counter_Var_Watched := Counter_Var;

Bonus_Out := Salary_In * 0.10;

END LOOP;

RETURN Bonus_Out;

END F_Calc_Bonus;

/

Page 213: Toad Users Guide

Chapter 8 PL/SQL Debugger 213

The Watch Properties Window

The Watch Properties window lets you set a number of options.

Package Variable

If the variable you want to watch is a package variable, check the package variablecheckbox. Also select the owner and package name. Otherwise, a watch variable isassumed to be within the current scope of the package procedure or packagefunction.

Repeat Count

In addition to the usual data types that you watch such as date, number and varchar,you can also watch array values and record types. If you have an array such asMyArray(1..10) and set up a watch on MyArray(1), then you can set up a RepeatCount setting of # to examine MyArray(1), MyArray(2), and MyArray(3) all at thesame time.

The Watch Properties window

Page 214: Toad Users Guide

214

Digits

The digits box is for the number of significant digits you want displayed.

Format

If you want the watch value displayed in a different format than the default, selectyour format options. Notice Default is preselected. Non-printable characters (ASCII0-31) embedded in strings can cause confusing errors and are difficult to debugbecause most fonts cannot render then in a meaningful way.

String\Dec displays non-printable characters, such as CR and LF in decimal format.For example, “This is a test.\013\010”

String\Hex displays non-printable characters in hexadecimal format. For example,“This is a test.\$D\$A”

Enabled

You can temporarily disable a watch by double-clicking the watch and uncheckingthe Enabled checkbox.ORSelect the watchRight-Click to display the Right-Click MenuSelect Disable Watch.

You might want to disable some watches to improve the performance of thedebugger. As each line of code is executed, each watch that was set has to beevaluated. So, the fewer watches the debugger has to evaluate, the faster it will run.

Page 215: Toad Users Guide

Chapter 8 PL/SQL Debugger 215

To edit a watch

1 Double-click the watch in the Watches window (Debug > Watches)ORSingle-click to select the watch. Click the right mouse button to display themenu

2 Select the Edit Watch menu itemORPress <CTRL>E.

3 The Watch Properties dialog window displays.

To delete a watch

1 Display the Watches window (Debug > Watches).

2 Select the watch.

3 Press <Delete>ORPress <CTRL>D.

Page 216: Toad Users Guide

216

Call Stack

The Call Stack window displays the chain of functions and procedures as they arecalled, in the order they are called, with the most recent function or procedure listedon the top. At the end of each procedure name is the current line number in thatprocedure. So, if procedure A line 5 called procedure B, then the call stack wouldlook like this: “Procedure B(1)” followed by “Procedure A(5).”

You can navigate among multiple procedures via the Call Stack window either byDouble-clicking the procedure name in the Call Stack windowORSelect the procedure.

Right-Click to display the Right-Click Menu.Select View Source.

See the Requirements section of this chapter (page 185) for information aboutenabling the Call Stack window feature.

This Call Stack window shows that you are on line 10 in procedure "Example".

Page 217: Toad Users Guide

Chapter 8 PL/SQL Debugger 217

DBMS_OUTPUT

You get to this dialog via the Database > DBMS_OUTPUT menu item.

Oracle provides a package, called DBMS_OUTPUT, which is specifically designedwith functions for debugging PL/SQL code. It uses a buffer, that your PL/SQL codewrites into, and then a separate process queries the buffer out and displays thecontents.

Output only comes out after the procedure has completed execution, not while youare single stepping through the code. In nested procedure calls, all procedures musthave run to completion before any DBMS_OUTPUT content is displayed.

The Procedure Editor Right-Click Menu lists DBMS_OUTPUT specific commands.

Buffer size defaults to 20,000 bytes. The maximum size is 1,000,000 bytes.

You can edit DBMS_OUTPUT content, make comments, delete specific lines ofoutput, etc. The standard copy, cut, and paste keys work in the DBMS_OUTPUTtextbox.

To create a DBMS_OUTPUT statement1 Highlight the desired selection from your SQL script.

2 Right-click to display the Right-Click Menu for the Procedure Editor.

3 Select the Make Output Statement item.

4 Click the place in your script where you want to paste the DBMS_OUTPUTstatement.

5 Select Paste from the Right-Click Menu OR the Edit menu.

6 The highlighted selection is now part of the DBMS statement and pasted intoyour script.

Page 218: Toad Users Guide

218

In this simple SQL script example....

ts

mpVar is highlighted and Make Output Statement iselected from the Right-Click Menu..
Page 219: Toad Users Guide

Chapter 8 PL/SQL Debugger 219

and pasted into the SQL script where the tmpvar is now part of the DBMS_OUTPUTstatement.

Page 220: Toad Users Guide

220

To view the DBMS_OUTPUT1 Select Debug > DBMS OUTPUT.

2 The DBMS_OUTPUT dockable window displays with the variable value listed,after execution of the procedure has completed.

ID

Remethe D

n the earlier example, TmpVar was set to = a+b+c which is 1+2+3, so theBMS_OUTPUT window shows the tmpvar value is 6.

Blank Output

You can also select Blank Output to get a DBMS_OUTPUT template which youpaste into your script and fill in the blank sections yourself.

To create a Blank DBMS_OUTPUT statement1 Right-Click to display the Right-Click Menu.

2 Select the Blank Output Statement item.

3 Click the place in your script where you want to paste the statement.

4 Select Paste from either the Right-Click Menu or the Edit menu.

5 The Blank DBMS_OUTPUT Statement is pasted into your script.

mber, if you have the Options > Debugging > Enable DBMS Output option on,BMS_OUTPUT window opens automatically after completion of the procedure.

Page 221: Toad Users Guide

Chapter 8 PL/SQL Debugger 221

Debug Functions

This section shows different debug functions and procedures.

NOTE: When debugging a procedure, if no breakpoints have been set and no errorsoccur, the procedure will execute to completion and it appears to have “donenothing.” This is a common cause of confusion when people first start using thedebugger. To avoid this confusion, if you haven’t set any breakpoints you mightwant to use the Step function <F8> instead of the Execute function <F11>.

To start a debug session with or without any argument values

1 SeORClORPr

2 De

3 If haNU

EXAMFUNCTI

Bonus_

BEGIN

/*

*/

Bo

DB

Re

END F_

E e

xecut

lect Debug > Execute Current Source

ick the Execute button

ess the shortcut keys <SHIFT>F9.

bugging begins and stops on the breakpoints as appropriate or runs to the end.

your procedure contains IN or IN/OUT argument values, and those valuesve not been set (via the Execute Procedure dialog), the values will be set to

LL.

PLE:ON F_CALC_BONUS (Salary_In IN Number) RETURN NUMBER IS

Out NUMBER;

Set Bonus earned equal to 10 percent of the employee’s salary.

nus_Out := Salary_In * 0.10;

MS_OUTPUT.PUT_LINE ( 'Bonus_Out = ' ||to_char(Bonus_Out));

turn Bonus_Out;

CALC_BONUS;

Page 222: Toad Users Guide

222

In this case, Salary_In would be set to NULL. This would not be very useful forfunctions that depend on argument values, but it is useful for checking branching,logic, etc.

If you set any argument values in the Execute Procedure dialog, then those valuesand settings will be used.

When debugging a package, you must select which package procedure or packagefunction to start debugging. You select this in the Execute Procedure dialog. Onceyou have selected the package procedure or function to execute, the Execute toolbarbutton is enabled.

If you debug a trigger, you have to go through the Execute Procedure dialog in orderto set up the anonymous PL/SQL block that will invoke the trigger.

To set IN or IN/OUT argument values

1 Select a package procedure to executeORSet up a trigger for debugging.

2 Select menu item Debug > Set ParametersORClick Set Parameters button on the Procedure Edit toolbarORPress the shortcut keys <CTRL>F9.

3 Set the desired parameters.

This does NOT execute the procedure or start debugging.

Select function/Set parameters

Page 223: Toad Users Guide

Chapter 8 PL/SQL Debugger 223

Execute ProcedureThere are different uses for the Execute Procedure dialog depending on the type ofPL/SQL object you wish to debug: Procedures, Functions, Package Procedures,Package Functions, or Triggers.

Execute Procedure or FunctionThis dialog lets you input values for the procedure or function arguments.

The Execute Procedure window

Page 224: Toad Users Guide

224

1 For each IN or IN/OUT argument, enter the desired values in the “Value”column.

2 When you finish entering argument values, click OK.

TOAD debugs the given PL/SQL procedure via an anonymous PL/SQL block. Asyou enter values, the anonymous PL/SQL block code updates.

You can also directly edit the anonymous PL/SQL code block. If you want toresynchronize the anonymous PL/SQL block with the values entered in the grid,click the Rebuild Code button. The Rebuild Code button becomes enabled whenyou make manual changes in the anonymous PL/SQL block.

Execute PackageWhen debugging packages, a list displays for you to select which package procedureor package function to execute. In the Procedure list, single-click to select a packageprocedure to debug, then enter your argument values in the “Value” column, ifdesired.

The Execute Package window

Page 225: Toad Users Guide

Chapter 8 PL/SQL Debugger 225

Debugging TriggersWhen a trigger is executed, a preprogrammed operation occurs on a table. You’llnotice that debugging triggers is different from debugging procedures or functions.The values entered are for the column values, not the argument values.

You must go through the Execute Trigger dialog to set up the proper anonymousPL/SQL block to invoke the trigger, at which point the Execute button on the Debugtoolbar becomes enabled.

Execute Trigger: INSERTWhen debugging an INSERT trigger, the values will be used as the values to insert.The inserted record will be rolled back so that no changes are made to the databaseduring debugging. The "INSERT INTO..." code is not valid until you enter columnvalues.

The Execute Trigger window

Page 226: Toad Users Guide

226

Executing Trigger: UPDATEWhen debugging an UPDATE trigger

1 Enter values for the “SET...” clause AND the “WHERE...” clause.

2 If the Where Clause Values checkbox is unchecked, enter the “SET...” values.If the Where Clause Values checkbox is checked, enter the “WHERE...”values.

3 The updated record will be rolled back so that no changes are made to thedatabase during debugging. The “UPDATE TABLE...” code is not valid untilyou enter the column values.

Page 227: Toad Users Guide

Chapter 8 PL/SQL Debugger 227

Execute Trigger: DELETEWhen debugging a DELETE trigger, you must enter values for the “Where...” clause.

With the “Where Clause Values” checkbox checked, enter the “WHERE...” values.

The deleted record will be rolled back so that no changes are made to the databaseduring debugging. The “DELETE FROM...” code is not valid until you enter thecolumn values.

Once a value is entered into the Value column of the grid, if you want to make itNULL again type the word NULL. Otherwise, the value will be the empty string.

In the case of multiple BEFORE or AFTER actions, INSERT takes priority overUPDATE, and UPDATE takes priority over DELETE.

Where clause values must be entered before you can debug a DELETE trigger.

Page 228: Toad Users Guide

228

Viewing OUT Argument ValuesIf you have OUT or IN/OUT arguments in your procedure, you can choose to viewtheir values during debugging in the Debug DBMS_OUTPUT window.

To view OUT or IN/OUT argument values1 From the Execute Procedure or Package or Trigger dialog, check the Output

OUT Args checkbox.

2 TOAD adds DBMS_OUTPUT.Put_Line statements at the end of the anonymousPL/SQL block used to invoke your procedure.

3 Turn on the Debug DBMS_OUTPUT window from the Debug menuORPress <CTRL><ALT>D.

Evaluate Modify

The Evaluate/Modify window lets you view the value of a variable on the fly,without having to set a watch. It also lets you change the value of a variable andcontinue executing. This is useful for advancing a loop variable to the end of a “FORCOUNTER_VAR IN 1..500 LOOP” loop statement. In this case, evaluateCounter_Var and set its new value to 499. So, you don’t have to debug through theloop the extra 498 times.

To display the Evaluate/Modify windowSelect Debug > Evaluate/ModifyORPress <CTRL><ALT>E.

Package Variable Checkbox

Check the Package Variable checkbox that’s in the Evaluate/Modify window, if thevariable to evaluate is a package level variable and not a local variable.

The Evaluate/Modify window is not dockable with the rest of the debug windows.

Page 229: Toad Users Guide

Chapter 8 PL/SQL Debugger 229

Preparing PL/SQL Code for Production

Once you have finished debugging your PL/SQL code, compile your procedure andany called procedures one last time. This recompiles it without the debug symboltables. This will make your code smaller, so it will run faster.

Page 230: Toad Users Guide
Page 231: Toad Users Guide

Schema Browser

The Schema Browser separates database objects by type, using tabs. For example, alltables appear on the Tables tab, all views appear on the Views tab, etc. Click on anindividual object in an object tab list at the left of the Schema Browser window todisplay the details on the details panels to the right of the Schema Browser window.So, you can quickly view all objects of one type with a single click of the mouse.You’ll find it a nice change from other database navigation tools which are oftenslow, cumbersome, burdened with excessive graphics, and hierarchical in approach.It also lets you compare details between objects of the same type with one click.Keyboard users can easily use the scroll keys to perform the same tasks.

3 ways to invoke the Schema Browser window

� Click the second button in TOAD’s main toolbar.

� Select menu item Database > Schema Browser.

� Set the Schema Browser to open automatically when a new connection is madein the View > Options > StartUp dialog.

Page 232: Toad Users Guide

232

Toolbars

The Schema Browser window consists of object lists on the left panel and details onthe right panel. Select a tab for objects on the left to display details for that selectionon the right panel.

These are the toolbars for the object lists on the left panel:

Object Toolbars

Tables

Indexes

Procs

Triggers

Sequences

Views

Synonyms

Constraints

Db Links

Java

Page 233: Toad Users Guide

Chapter 9 Schema Browser 233

Object Toolbars Buttons Functions

Some button icons are common to more than one Object tab.

Create a script for the selected object, copy it to the clipboard

Export data from the selected table as "INSERT INTO..." statements to either theclipboard or to a file

Add or change privileges of the selected object to/from other users or roles

Filter to only display objects that meet a certain criteria, e.g., "Starts with ABC...","Contains", "Ends With", or other object type specific criteria

Add a column to the end of a table

Truncate all data in the table via the no-rollback DDL Truncate command

Add a table constraint

Analyze a Table or Index

Drop the selected object from the database

Drop all filtered objects for the current object tab from the database

Rebuild the selected index

Save the selected object to a SQL file

Open the selected object in a SQL Editor or Stored Procedure Editor

Compile Procedure, Trigger, View, or Java object

Compile all Procedures or Views

Compile dependent procedures

Execute procedure

Page 234: Toad Users Guide

234

Enable all Triggers or Constraints

Disable all Triggers or Constraints

Enable current Trigger or Constraint

Disable current Trigger or Constraint

Create new Sequence or Database Link

Add Public Synonym for Table or Sequence

Page 235: Toad Users Guide

Chapter 9 Schema Browser 235

Right-Click Menus

Object Lists

The Right-Click Menu on any of the tabs in the objects panel (the left-hand side ofthe window) displays a menu to show/hide the object tabs. You can check oruncheck menu items to show or hide the tabs. However, you cannot hide the tablestab. So, if you only want Views and Synonyms, deselect the rest for a cleanerinterface. When you exit, TOAD saves your options. The next time you run TOAD,the window will hide the tabs that you unchecked in your previous session.

Right-click on a tab in the objects panel to display a Right-Click Menu thatlists all the object tabs, which you can select or deselect. Here, the Triggersand Db links are unchecked in the tab list, so they are not displayed.

Page 236: Toad Users Guide

236

Data Grids

The Data grids on the Tables > Data tab and the Views > Data tab also have aRight-Click Menu.

The Data Grids Right-Click Menu is similar to the Right-Click Menu that is in theSQL Editor Results Grid. For detailed information on each of these items, refer tothe SQL Editor chapter - the Results Grid section, page 102.

The Schema Browser data grids menu also contains: Post Changes/Edit. It does notcontain Export to Flat File, Find Data, Font, or Size Columns to Data.

Data Grids Right-Click Menu

Page 237: Toad Users Guide

Chapter 9 Schema Browser 237

Using the Schema Browser

The Schema Browser has the objects on the left panel and the details on right panel.The tabs for the objects will display the corresponding details. When you click onany individual object on the left, details or the DDL structures for that object aredisplayed in the right panel.

All the tabs that show in the details panel are details for the selected object. The Javatab is only for the Oracle 8i database.

For performance, TOAD delays fetching some schema lists until the tab that requiresthat list is activated.

The vertical splitter between the objects panel and the details panel can be movedleft or right via click and drag.

When you first open the Schema Browser, the Tables Tab is selected by default, anda list of all the tables in the selected schema displays.

The dropdown box above the Object Tabs lets you select the desired schema.

If you want to narrow the list of schemas in the schema dropdown list you have twochoices, Show only schemas that own objects and Oracle User List. For detailsabout “Show only schemas that own objects” see the Schema Browser options. Toset up a specific list of Oracle users (schemas) that you want to see, select menu itemView > Oracle Users List. This opens the Configure User Lists dialog where youcan multi-select any combination of users you want to see. This list is saved andrestored in a file named schema_databasealias.lst, e.g., SCOTT_ORA8I.LST, in theTOAD\TEMPS folder. From that point forward, any dialog in TOAD that presents aschema dropdown list will be restricted to the schemas you select, e.g., the “TableName Select” dialog or the “Column Name Select” dialog.

The drop down box lets you choose your schema.

Page 238: Toad Users Guide

238

If an Object Tab doesn’t contain any objects then the Object Tab window will beempty for that tab.

If you’re not a DBA, you’ll only see your own objects and objects that you’ve beengranted permission to see. So, if you view another user’s schema, you only seeobjects in that schema that the other user has granted you permission to see. DBA’scan see everyone’s objects.

The Change Active Session button has a dropdown button next to it. Its dropdownlist displays all active sessions. You can click on a session from the list to change theactive session. If you want to create another session, click the change active sessionbutton which will bring up the “Select Session” dialog where you can then click the<NEW> button to create the new session.

The status panel shows what session you’re in. The CNT on the status panel showshow many objects are in the object list for the object tab you’ve selected.

The Change Active Session drop down list lets youselect a different session as your active session.

The status panel for this Table window showsthe number of objects in the window is 15, thecurrent session is System, and Commit is ON.

Page 239: Toad Users Guide

Chapter 9 Schema Browser 239

The Refresh All button refreshes the current list. So, if you create a table and youdon’t see it in your table list, click Refresh All which will requery, and the tablename should display in the list, subject to any active table filters.

The Refresh Detail button, refreshes, or requeries, only the details panel. So, if youdropped a column, you can click on the refresh detail to see the refreshed list.

Clear Filters only affects the two data tabs, because they are the only ones with datafilters.

On the Tables > Data tab and Views > Data tab, there is a filter button whichdisplays a dialog where you can sort or filter.

� When the filter funnel is red, it’s ON.

� When the filter funnel is gray, it’s OFF.

� When there are not filters, the filter is gray, and it’s OFF.

Refresh All

Refresh Detail

Clear Filters

Data Filter

Page 240: Toad Users Guide

240

Object Filter

The following tabs have object name filtering capability: Tables, Procs, Triggers,Views, Synonyms, and Constraints. Click the filter toolbar button and enter the filtercriteria, e.g., starts with A, etc.

When viewing Packages and Procedures, you may see "wrapped" rather than thecode of the statement. This means that the procedure was compiled using the Oraclewrap utility and is not stored in readable format.

Page 241: Toad Users Guide

Chapter 9 Schema Browser 241

Options for the Schema Browser

You get to the Schema Browser Options menu through View > Options > SchemaBrowser item.

Page 242: Toad Users Guide

242

Enable DROP-ALL Buttons

Default - Unchecked

Most object list tabs in the Schema Browser have a Drop All button which allowsfast dropping of database objects. The Drop-All buttons are never enabled unlessyou check this option. TOAD will not save this option and will revert to disabledDrop-All buttons. So, checking this option is temporary for the current TOADsession only.

Omit SYS objects from the Procedure Dependencies List

Default - Checked

If checked, TOAD will omit SYS owned objects from the Procedure Dependencieslist, such as standard packages, DBMS_STANDARD, DBMS_UTILITY, etc.

Show Table Stats for Table Details (on the Stats/Size tab)

Default – Checked

If checked, TOAD will show the table stats information. You can also check this ONor OFF via checkboxes on the Stats/Size tab.

Show Column Length Info with Column Data Type

Default – Checked

If checked, columns will show, in the columns tab, in the format "VARCHAR2(20)"including max length, scale and precision (if applicable). If unchecked, length, scale,and precision will display in separate columns in the grid.

Limit Data Grids To X Number of Rows

Default – Blank (all rows)

If a value is entered, SQL results grids on the Tables > Data tab and the Views >Data tab are limited to that number of rows. This does not affect the SQL results gridon the SQL Edit window.

Page 243: Toad Users Guide

Chapter 9 Schema Browser 243

Automatically Show Filter Dialog for Filtered Lists on Browser

Default – Unchecked

If checked, before the Schema Browser window is opened a Filter Dialog willdisplay for the user to enter filter criteria, then the Schema Browser will open withonly those objects matching the filter.

Add View Columns to View Text When Creating Scripts or Showing View SQL

Default – Checked

If checked, a list of columns displays that will result when the view is queried, afterthe "create or replace view" clause, e.g., "create or replace view view_name (col1,col2, ..., coln) as ..."

Only Show Users That Own Objects in Dropdown Lists

Default – Unchecked

If checked, TOAD will only show the users who own objects. This is an alternativeto Oracle User List selection process. For example, if your environment includesonly a few schemas that own objects granted to hundreds of schema names forsecurity purposes, then checking this option will list only the few schemas that ownobjects instead of a long list of all the schemas. So, this filter makes the schemadropdown list more manageable.

NOTE: This option affects all windows in TOAD with Schema dropdown lists, e.g."Table Name Select", "Column Name Select", etc.

Only Show One Browser Per Database Connection

Default – Unchecked

If checked, TOAD will only permit one Schema Browser window to be opened perOracle connection. This conserves operating system resources, because the SchemaBrowser is loaded with widgets, buttons, and bitmaps. If the user tries to createanother Schema Browser window, and one is already open, TOAD will just switch tothe existing Schema Browser window.

This option is similar to limiting the number of SQL Edit windows in the SQL Editoroption (Only show one SQL Editor per database connection) and Procedure Editwindows in the Procedure Editor options menu.

Page 244: Toad Users Guide

244

Cache cursors used for Browser queries (faster Browser but uses 12 cursors)

Default – Checked

If checked, TOAD will use cursors when retrieving detail information to display inthe details panels to the right of the Schema Browser window. Usually, only theobject name changes from query to query. So the use of cursors, where only the bindvariable values change, is much faster than forcing Oracle to reparse and re-executedifferent queries each time.

Show List of Primary Key Columns for tables

Default – Checked

When checked, TOAD will display the list of Primary Key columns, on theTables/Columns tab, to the right of the Show Comments dropdown list. For sometables with long column names, and/or compound primary keys, this label may notbe long enough. TOAD also places a small black triangle next to each column in thecolumns list that is a Primary Key column.

Auto-Expand Dependencies Trees

Default - Unchecked

If checked, when dependencies display, they are automatically expanded. Ifunchecked, each level is queried and displays as the user drills down.

Auto-size list view columns

Default – Unchecked

If checked, TOAD will automatically size the width of the column lists to the widthof the text.

Save Data Grid Layouts

Default – Unchecked

When checked, TOAD will automatically save the Data tab grid layouts with respectto column order, columns to exclude, sort, filter, and custom column widths.

Page 245: Toad Users Guide

Chapter 9 Schema Browser 245

Save Browser Filters

Default – Checked

If checked, TOAD will save the browser filters to disk, in files namedSCHEMA.FLT in the \TOAD\TEMPS folder.

If you want to reset your Schema Browser filters each time you close and openTOAD, then uncheck this option.

Show Tablenames following Triggers names

Default – Unchecked

If checked, corresponding tablenames will display after trigger names on the triggersobject list.

Page 246: Toad Users Guide

246

Objects

Object Scripts

TOAD can create DDL Scripts -- Oracle Statements to recreate the object -- for mostof the objects displayed on the Schema Browser. The Create Script button, which isthe first button on the toolbar for each tab on the left of the Browser, generates ascript. The scripts are always copied to the clipboard by default.

Note: Table create scripts can be viewed while on the Browser window on the“Scripts” detail tab for Tables.

Dropping Objects

Many objects can be dropped directly from the Schema Browser. Tables, Indexes,Procedures, Functions, Packages, Triggers, Sequences, Views, Synonyms,Constraints, Database Links, and Java objects can be dropped via buttons on therespective tabs on the left of the Browser window.

The Tables Tab list the tables that are in the selected schema.

Page 247: Toad Users Guide

Chapter 9 Schema Browser 247

The buttons for dropping a single object are enabled whenever an object is selectedin the list on the respective tab. The Drop All buttons are not enabled by default. Youmust manually enable them on the View > Options window. This makes apotentially destructive operation a little more complex. The Drop All setting is NOTsaved, and must be reselected each time TOAD is started. Notice the drop a singleitem scissors icon are cutting a white piece of paper and the Drop All icon hasscissors cutting a red piece of paper. This is a visual alert, so that you will notaccidentally select Drop All instead of a simple Drop a single object.

TOAD will confirm any DROP operation on the Browser but after yourespond <Yes> to the confirmation, NO DROPS CAN BE REVERSED.

Copying From the Browser

Any of the Object Names shown in the Object Lists on the left of the Browser can becopied to the clipboard by pressing <CTRL>C for the highlighted object name.

Any column of data shown in the detail grids on the right of the Browser can becopied to the clipboard by pressing <CTRL>C for the highlighted grid cell.

The Enable DROP-ALL buttons option is unchecked by default.

Page 248: Toad Users Guide

248

Note that the detail grids for Table Information behave differently. The grids thatdisplay Table Detail Information support multi-row selection and always copy thefirst column to the clipboard. For example, if you are viewing a grid display of a listof columns for a table, you can <CTRL>-click to select more than one column, andthen press <CTRL>C. This will copy your selected columns to the clipboard, withcommas in between (a comma-delimited list). Then you can paste the list into a SQLEditor or another application.

Selecting Object Tabs

Individual Tabs on the left side of the Browser window can be hidden if there aredatabase objects you do not need to see often. Right-click over the tabs. A popupmenu lets you select only the tabs you want to view. The selections are preservedbetween TOAD sessions. You cannot unselect the Tables tab.

Filters

Most of the primary lists of objects on the Browser can be filtered to show a subsetof all of the like objects in the schema. For example, you may have hundreds oftables in a schema but only want to see those where the table name begins with"GEO." Filters currently exist for Tables, Constraints, Synonyms, Views, Triggers,and Procedures.

Browser Filters are specific to a schema/owner name. This means you can define onefilter for the schema DEMO and a different filter for PRODUCTION and theappropriate filters will be loaded when you view that schema in the SchemaBrowser.

Table Filters allow filtering on table name as well as column name. For example,you can find all tables that have columns with FND_NO anywhere in the columnname. The table name may also be searched.

Constraints can be searched by constraint name or constraint column name.

Synonyms can be filtered by Synonym scope: Owned by schema only, owned byschema plus Public synonyms, exclude SYS and SYSTEM synonyms, etc.

Page 249: Toad Users Guide

Chapter 9 Schema Browser 249

Note: for performance reasons, TOAD caches the list of tablenames for the currentschema once the list has been queried from any window. The browser filter, althoughprimarily intended to filter the Schema Browser window, also affects the table liststhroughout TOAD. So, for example, if your filter is set to display only tables thatbegin with GEO, every table list will display a filtered list until the filter is changed.

Also note that the filters not only reduce the amount of data displayed, they alsomodify the query used to fetch the data. So, not only is the display refreshed faster,the query fetches less rows for faster response from the database.

If no filters are defined, the Browser displays the following:

� Tables that do not get filters� Constraints show primary keys only� Synonyms show all but exclude those for objects owned by SYS & SYSTEM� Views display all Views� Triggers display all Triggers� Procedures display all Procedures

The filters for all Browser objects can be viewed in a single window under theView > Browser Filters menu.

Note: Browser filters are not applied when making changes to the View > BrowserFilters dialog. To apply the filters, you must click the Filter toolbar button on thedesired object tab, e.g., Constraints, to bring up the Browser Filters dialog, whereyou can select constraint options, click the OK button, and then the browser filtersare applied.

Page 250: Toad Users Guide

250

Object Tabs

The Schema Browser Object tabs are broken down into two groups. On the left is theObject Type. On the right are the details panels that fully describe the objects.

OBJECT TYPE TAB PANELS THAT DESCRIBE THE OBJECTS

Tables Columns, Indexes, Constraints, Triggers, Data, Scripts,Grants, Stats/Size, Referential, and Used By

Indexes Columns, Position, Length, Table Name and TableOwner

Procs Arguments, Dependencies (Uses), Dependencies (UsedBy), Errors, Grants

Triggers Columns, Tables, Table Owner, Usage, and TriggerText

Sequences Starts With, Max Value, Increment by, Cycle, etc.

Views View Columns, Data, Grants, Dependencies, View Text

Synonyms Object Owner/Name/Type, and if Synonym points to atable, view or PL/SQL code, the appropriate describewindow tabs display

Constraints Constraint Columns/Text, Referential Owner

Database Links Host, Username, Created Date

Java (no GUI is defined for Java objects at this time)

Page 251: Toad Users Guide

Chapter 9 Schema Browser 251

Tables

This section discusses the Tables Tab. Remember, some of these buttons are alsofound on other tabs.

Objects Panel

Create Script

The Create Script button displays a Table Script Creation window.

Create Script button

Page 252: Toad Users Guide

252

When the Table Script Creation window displays, the Options Tab is selected bydefault.

When you select the Execute button, a script is created for your table that you canthen paste into the SQL Editor or elsewhere.

For creating multiple table scripts, see the Database > Export > Table Scriptsmenu item.

Table Script Creation Options

Include Drop statement in script

If checked, this will include a DROP statement at the top of the table script.

DROP TABLE SALGRADE CASCADE CONSTRAINTS ;

CREATE TABLE SALGRADE (

GRADE NUMBER,

LOSAL NUMBER,

HISAL NUMBER)

Include indexes in script

If checked, TOAD will include CREATE statements for each index on the table.

CREATE INDEX JUNK ON ACCT_BALANCE(OPBAL_CR);

Include tablespace info

If checked, TOAD will place TABLESPACE and STORAGE clauses after theCREATE TABLE and CREATE INDEX commands.

TABLESPACE USER_DATA

PCTFREE 10 PCTUSED 40

INITRANS 1 MAXTRANS 255

STORAGE (

INITIAL 10K NEXT 10K PCTINCREASE 50

MINEXTENTS 1 MAXEXTENTS 121 )

NOCACHE;

Page 253: Toad Users Guide

Chapter 9 Schema Browser 253

Separate Check constraints

If checked, TOAD will place check constraints after the CREATE TABLEcommand.

If unchecked, it will place the check constraints inside the CREATE TABLEcommand.

CONSTRAINT ACCT_BAL_CHECK_CONSTRAINT

CHECK (compcode >= 'AA' and compcode <= 'ZZ')

Separate Unique Constraints

If checked, TOAD will place unique constraints after the CREATE TABLEcommand.

If unchecked, it will place the unique constraints inside the CREATE TABLEcommand.

ALTER TABLE UNIQUE_TEST ADD CONSTRAINT UNIQUE_TEST_UK

UNIQUE (NAME);

Include Comments

If checked, TOAD will include table and column comments.

COMMENT ON TABLE ACCT_BALANCE IS 'This is a test.';

COMMENT ON COLUMN ACCT_BALANCE.COMPCODE IS 'Only compcodes AA-ZZ are

valid.';

Include Synonyms

If checked, TOAD will include a PUBLIC synonym to the table.

CREATE PUBLIC SYNONYM ACCT_BALANCE FOR ACCT_BALANCE;

Include Foreign Key constraints

If checked, TOAD will include the foreign key constraint clauses for the table.

Page 254: Toad Users Guide

254

ALTER TABLE DIS ADD

FOREIGN KEY (PLANT_ID)

REFERENCES TSMITH.PLANTS (PLANT_ID) DISABLE;

Foreign Keys at end of script

If checked, TOAD will place the foreign keys at the end of the script.

If unchecked, TOAD will place the foreign key clauses inside the CREATE TABLEstatement.

Include Enable/Disable for Ref constraints from other tables

If checked, TOAD will disable and enable referential constraints from other tables tothe table for which you are creating a script.

Include granted privileges

If checked, GRANT statements will be included at the end of the script.

GRANT SELECT ON PLANTS TO DEMO;

Include Triggers

If checked, TOAD will include the trigger code for the table at the end of the script.

CREATE OR REPLACE TRIGGER SCHAPMAN.TABLE_TO_VALIDATE_IU

BEFORE INSERT OR UPDATE ON table_to_validate

FOR EACH ROW

BEGIN

/* Call the proc to validate the incoming value. */

check_validated_value(:new.value_to_validate);

END TABLE_TO_VALIDATE_IU;

Page 255: Toad Users Guide

Chapter 9 Schema Browser 255

Include SQL * Plus / chars.If checked, TOAD will include "/" characters after every command in the script.

DROP TABLE ...

/

CREATE TABLE ...

/

Primary Key with Indexes Script

If checked, TOAD will place the Table Primary Key with the indexes portion of thescript.

NOTE: This option is mutually exclusive with the Primary Key with Table Createradio button.

ALTER TABLE ACCT_BALANCE

ADD CONSTRAINT ACCT_BALANCE_PK

PRIMARY KEY (COMPCODE, FISCALYEAR, ACCTCODE, OFFCODE)

USING INDEX

TABLESPACE USERS PCTFREE 10

STORAGE(INITIAL 10240 NEXT 10240 PCTINCREASE 50 ) ;

Primary Key with Table CreateIf checked, TOAD will place the Table Primary Key inside the CREATE TABLEstatement.

NOTE: This option is mutually exclusive with the Primary Key with IndexesScript radio option button.

RUN_CR_13 NUMBER(13,2),

CONSTRAINT ACCT_BALANCE_PK

PRIMARY KEY ( COMPCODE, FISCALYEAR, ACCTCODE, OFFCODE )

USING INDEX PCTFREE 10

STORAGE(INITIAL 10240 NEXT 10240 PCTINCREASE 50 )

TABLESPACE USERS)

Page 256: Toad Users Guide

256

No trailing semicolons

If checked, TOAD will not place semicolons at the end of each statement.

NOTE: This option is mutually exclusive with the Add trailing semicolons radiobutton.

Add trailing semicolons

If checked, TOAD will place semicolons at the end of each statement.

NOTE: This option is mutually exclusive with the No trailing semicolons radiooption button.

DROP TABLE ACCT_BALANCE CASCADE CONSTRAINTS ;

Output Tab

To Clipboard

If checked, TOAD will output the table script to the Windows Clipboard.

To File

If checked, TOAD will output the table script to a single file, as selected in theFilename textbox.

Filename textbox

Enter a drive, path, and filename, or click the drill down (ellipses) button for thestandard file picker dialog.

Click the Execute button to generate the table script, or click the Cancel button toclose the Table Script Creation dialog.

The options selected in the Table Script Creation dialog are saved and restored thenext time you create a table script.

Page 257: Toad Users Guide

Chapter 9 Schema Browser 257

The Export Data function creates “INSERT INTO” SQL statements for the data inthe selected table. The Export Data button displays the Data Export window forwhatever table is selected from the left panel of the Table Tab.

Columns Tab

You can check/uncheck columns you wish to include/exclude. TOAD checks all thecolumns by default.

Here, the User Profile object was selected, the Export Data button was clicked,and this was the resulting Data Export window.

Export Data

Page 258: Toad Users Guide

258

Exclude Null Columns

If checked, TOAD will exclude null columns from the columns clause and the valuesclause of the “INSERT INTO” SQL statement.

E.g.,

INSERT INTO Foo ( ID ) VALUES (5);

INSERT INTO Foo ( ID, NULL_COL_TEST2 ) VALUES (6, 2);

INSERT INTO Foo ( ID, NULL_COL_TEST ) VALUES (7, 1);

INSERT INTO Foo ( ID ) VALUES (8);

INSERT INTO Foo ( ID ) VALUES (9);

INSERT INTO Foo ( ID ) VALUES (9);

Exclude Primary Key Columns

If checked, your primary key columns will be excluded. If you do not have anyprimary key columns, this choice will not be enabled.

Select All /Unselect All

The Select All and Unselect All buttons lets you quickly Select or Unselect all thecolumns. You can then selectively check/uncheck the columns you want toinclude/exclude.

Page 259: Toad Users Guide

Chapter 9 Schema Browser 259

Options Tab

Where... clause

The Where clause is optional. You do not have to include a where clause.

If you include a Where clause you must include the word “Where” in your statement.Example:

WHERE INVENTORY_NUMBER = 943

Destination

Default – To File

The Destination radio buttons let you choose between To Clipboard or To File.

Filename

The filename area has a drill down button where you can drill down to the desiredfile. You must supply a file name.

Include Schema/Owner Name in Insert Statements

When this radio button is selected, the Schema or Owner Name will be included ininsert statements.

E.g.,

INSERT INTO Schema.Foo ( ID ) VALUES (5);

Page 260: Toad Users Guide

260

The Table privileges button activates the Privileges window.

Use this window to view or modify the privileges of the selected table, view,procedure, or sequence to other user schema accounts or roles.

The Privileges window is discussed in more detail in the Grants Section of thisTables Tab Section page 278.

The Table Filter button displays the Browser Filters window for the Tables.

The Browser Filters button can be found on the tabs for Tables, Procedures,Triggers, Views, Synonyms, and Constraints. All the Browser Filter windows have asimilar interface.

Here, all tables in the SCOTT schema will be filtered out except those withTablenames that begin with EMP.

Table Privileges

Table Filter

Page 261: Toad Users Guide

Chapter 9 Schema Browser 261

Browser filters are helpful for schemas that contain a lot of objects— the fewerobjects that TOAD needs to load, the faster it will execute. For example, you cannarrow the focus to only tables whose names begin with EMP and temporarily ignoreall other objects in the schema.

Dropdown filter lists include the following choices:� Starts with� Includes� Ends with� Not like

After you set your filters, select OK and the browser will display the resultingobjects.

To view all the objects again, simply select the filter button, Clear the filters byselecting Clear where you have filters, and then select OK.

The filter is stored in a file named SCHEMA.FLT in the TOAD\TEMPS folder,where SCHEMA is the schema name. Do NOT attempt to edit this file!

To set up a default filter, see View > Browser Filters, then click the Show DefaultFilter button. Set up your default filters and press OK to close the window. Thesefilters will be set up by default each time the Schema Browser window is opened.

You can also use this dialog to set up the default filter, which is in force for everynew schema.

You can set defaults for Tables, Constraints, Synonyms, Views, Triggers, andProcedures, such as starts with, contains or ends with a keyword.

If you select multiple filters, e.g., table name and tablespace name, then they arejoined together with an AND statement in the SQL as opposed to an OR statement inSQL.

Not Like sets up the tablename query like this: [not like KEYWORD%].

Page 262: Toad Users Guide

262

Add Column

Click the Add Column button to display the Column Definition window. Thisdialog lets you add a column to the selected table. You must enter the Column Name,the Type, and the Size. The Nullable radio button is selected by default.

If you want to see the resulting SQL script of your command, select the SQL tab.

Page 263: Toad Users Guide

Chapter 9 Schema Browser 263

To Add a Column1 Enter the column name, data type, and other appropriate information.

2 Click the Execute button to add the column.

Character Default Values have to be wrapped within single quotes, in order to makea valid "ALTER TABLE..." statement.

Additional columns are always appended to the end of the table definition. Youcannot insert columns.

The Database > Rebuild Table function lets you remove columns or renamecolumns in a table. The Oracle 8i feature of the "ALTER TABLE" command letsyou DROP individual columns.

Truncate Table

Lets you truncate a table (delete all the data but maintain the table structure) andeither reuse the storage or drop it. The following dialog will display when you selectthe button.

Once you click the Execute button you can’t rollback or undo your choice.

Page 264: Toad Users Guide

264

Create Constraint

The Create Constraint button activates the Create Constraint window.

Use this dialog to create additional table constraints.

You can also get to this dialog via the Create > Constraint menu item.

You can create:

� Primary Key constraints� Check constraints� Unique constraints� Foreign Key constraints

Page 265: Toad Users Guide

Chapter 9 Schema Browser 265

To Create Primary Key Constraints1 Type the constraint name in the Constraint Name box.

2 If desired, select the Create Constraint Disabled checkbox.

3 Select the “from” schema and “from” table from the dropdown lists. That willquery and populate the columns into the Table Columns list.

4 Click the Primary Key option button.

5 From the Table Columns list, select the column or columns you want designateas the primary key. (To select more than one item press the <CTRL> key whileclicking on the item(s).)Optionally select the storage parameters.

6 Click the right arrow button to move your selected item(s) to the ConstrainedColumns panel.

If you want to move records that do not meet the new constraint criteria into anothertable, click the Exceptions tab, pick a schema, existing table, or enter a new tablename, and click the Create a New Exceptions Table button.

7 You can review the SQL prior to execution by clicking the SQL tab.

8 Click the Execute button to create the Primary Key constraint.

If a Primary Key constraint already exists for the selected table, then the PrimaryKey radio button option will be disabled.

Page 266: Toad Users Guide

266

To Create Check Constraints1 Type the constraint name in the Constraint Name box.

2 If desired, select the Create Constraint Disabled checkbox.

3 Select the “from” schema and “from” table from the dropdown lists.

4 Click the Check option button.

5 Enter the check constraint text, in the Check Constraint Condition textbox,e.g., "SALARY < 100000 and COMMISSION > 5000."

If you want to move records that do not meet the new constraint criteria intoanother table, click the Exceptions tab, pick a schema, existing table, or enter anew table name and click the Create a New Exceptions Table button.

6 You can review the SQL prior to execution by clicking the SQL tab.

7 Click the Execute button to run the SQL and add the Check Constraint.

To Create Unique Constraints1 Enter the Constraint Name.

2 If desired, select the Create Constraint Disabled checkbox.

3 Pick the “from” schema and the “from” table from the dropdown list. That willpopulate the Table Columns list.

4 Click the Unique radio button.

5 From the Table Columns list, select the column(s) that you want to be theConstrained Column(s). Optionally select the storage parameters.

6 Click the right arrow button to move your selection(s) to the ConstrainedColumns window.

If you want to dump records that do not meet the new constraint criteria into anothertable, click the Exceptions tab, pick a schema and existing table, or enter a new tablename.

7 You can review the SQL prior to execution by clicking the SQL tab.

8 Click the Execute button to run the SQL and add the Unique Key constraint.

Page 267: Toad Users Guide

Chapter 9 Schema Browser 267

To Create Foreign Key Constraints1 Enter the Constraint Name.

2 If desired, select the Create Constraint Disabled checkbox.

3 Pick the “from” schema and the “from” table from the dropdown list. That willpopulate the Available Table Columns list.

4 Click the Foreign Key option button, and optionally check the Cascade Deletescheckbox.

5 On the This Table tab, select the column(s) that you want to be theConstrained Column(s).

6 Click the right arrow button to move your selection(s) to the ConstrainedColumns window.

7 Click the Referenced Table tab.

8 Select the Referenced Table schema, table, and column(s). (To select morethan one item press the <CTRL> key while clicking on the item(s).)

If you want to dump records that do not meet the new constraint criteria intoanother table, click the Exceptions tab, pick a schema and existing table, orenter a new table name and click the Create a New Exceptions Table button.

9 You can review the SQL prior to execution by clicking the SQL tab.

10 Click the Execute button to run the SQL and add the Foreign Key constraint.

Page 268: Toad Users Guide

268

Click the Analyze Table button to display the Analyze Tables window.

Use this dialog to analyze the selected table from the tables object list. This collectsstatistics so that COST based query optimization can be used. So, the optimizer canrun better queries.

You can either estimate statistics (faster than compute), compute statistics, or deletecurrent statistics.

To analyze all tables in the current schema or other selected schema, go to theDatabase > Analyze All Tables menu item. This displays the same dialog as above,but with the Schema dropdown list enabled so that you can select which schematables to analyze all at once.

Analyze Table

Page 269: Toad Users Guide

Chapter 9 Schema Browser 269

Click the Add Public Synonym for this Table button and a confirmation windowwill appear asking if you want create a public synonym for the table. The Sequencestab also contains an Add Public Synonym toolbar button.

Click Yes to create the synonym or No to Cancel.

The Drop Table button lets you drop the selected table directly from the SchemaBrowser. A confirmation window will ask you if you are sure you want to drop thetable. Once you select Yes the table is dropped and cannot be retrieved.

Add Public Synonym to Table

Drop Table

Page 270: Toad Users Guide

270

Tables Details PanelThe Tables details panel has tabs for displaying different details about the selectedtable.

Columns

The Columns tab lists all the columns for the selected table. It also displays eachcolumn Data Type, whether or not the column accepts Null values, columnattributes (such as length, precision, scale), Default value, and column comments, ifany. You can change the length, precision, scale display to “NUMBER(10,5)”through the TOAD Option > Schema Browser > Show Columns Length Info withColumn Data Type setting.

The dropdown default is Show no comments. The other choices in the dropdown areColumn Comments and Table Comments, which show the comments in an overlaypanel at the bottom of the details panel. You can type directly into this panel to editthe various comments. To save the comment edits, just select a different column ortable.

Primary Key columns are indicated by small black right triangles to the left of thecorresponding column names. A label to the right of the comments dropdown listdisplays the Primary Key column name(s).

You can multi-select columns, press <CTRL>C to create a comma-delimited list ofcolumns to the windows clipboard, and paste the selection into an editor.

Indexes

The Indexes tab lists the indexes for the selected table. The list includes the IndexName, whether or not the index is Unique, the Column(s), and the Position. It alsolists the Parameters and Values for each index.

Indexes Details Panel Buttons

Create script for selected index

Create new index

Rebuild index

Analyze index

Drop index

Drop all indexes, not enabled by default

Page 271: Toad Users Guide

Chapter 9 Schema Browser 271

Constraints

The Constraints tab lists any constraints for the selected table. It lists the ConstraintName, the Constraint Type, the corresponding Column, and the Status.

For foreign key referential integrity constraints, the panel at the bottom lists theowner, table, and column names that the foreign key constraint is pointing to.

Constraints Detail Panel Buttons

Enable ALL Constraints for this table

Disable ALL Constraints for this table

Enable the current Constraint

Disable the current Constraint

Drop ALL Constraints, not enabled by default

Drop Constraint

Page 272: Toad Users Guide

272

Triggers

The Triggers tab lists any triggers for the selected table. It includes the Type, Status,whether or not it’s Enabled, the Trigger Event, the Table Owner, and the WhenClause.

The editor at the bottom of the details panel lists the source code for the selectedtrigger.

Trigger Detail Panel Buttons

Enable ALL Triggers for this table

Disable ALL Triggers for this table

Enable the current Trigger

Disable the current Trigger

Drop ALL Triggers, not enabled by default

Drop Trigger

Open Procedure Edit window for selected trigger

Page 273: Toad Users Guide

Chapter 9 Schema Browser 273

Data

The Data tab displays the selected table, with data, in grid format. This is similar tothe SQL Results Grid on the SQL Edit window with just a few differences. The datain this grid is directly editable, because the query to populate the grid includes theROWID column. The right mouse menus are slightly different. Grid configurationson this data tab are saved and restored from the TOAD\TEMPS folder structure.

You can easily rearrange columns by clicking and dragging on the column titles.

Double-click any data item to bring up a memo editor for that item.

Click on the book in the top left corner of the table to show single record views ofthe selected row.

Details Panel

The Filter Data toolbar button opens the Table Sort dialog, where you can selectthe columns to sort and/or filter.

Commit the grid edits to the database

Filter the data grid, set sort criteria

Single record view button

Page 274: Toad Users Guide

274

Table Sort Window

Sort Tab

To Sort, select the column(s) you want to sort and click on the pointing hand. Noticeyou can sort in ascending or descending order. You can also move items up anddown the list. If you want to clear the sort column(s) for this table, click the ClearSort button. If you want to clear the entire filter for this table, click the Clear Filterbutton on the Table Sort dialog.

Filter Tab

The filter tab provides dropdowns with additional filter choices. On the filter tab,select the Column, Operator, and Value to filter upon. You can further edit theresulting SQL right in the memo editor widget.

When finished, click OK and the data in the grid will be sorted and/or filtered asspecified.

This sort and filter criteria are saved in temporary files in the TOAD\TEMPS folderhierarchy.

If a table filter is in effect, the funnel icon on the Data tab will be red.

The Clear Filters toolbar button clears the filter criteria and the sort criteria.

Page 275: Toad Users Guide

Chapter 9 Schema Browser 275

Data Detail Buttons Continued

The forward and backward buttons let you quickly move around from row to row inthe recordset. The First Record button takes you to the top of the grid (the first recordin the recordset). The Next Record button takes you to the next record in therecordset, and so on.

Insert record (blank row) over current row

Delete record

Post edit

Cancel edit

Refresh data

Advance to the first record

Advance to the previous record

Advance to the next record

Advance to the last record

Page 276: Toad Users Guide

276

Scripts

The scripts tab displays the SQL script for the table you’ve selected.

The scripts tab also includes several buttons and options.

The Copy Text to Clipboard button (or <CTRL> C) copies selected text from theSQL script to the clipboard, so that you can paste it into another application or texteditor.

The Select All Text button selects all the text in the SQL script. You can then use theCopy Text to Clipboard button to copy the whole script.

The Copy Script to a SQL Edit window button opens a SQL Edit window and pastesa copy of the script into the SQL Edit window.

The options you can check or uncheck are:� FKeys� Indexes� Synonym� Grants� Storage� Triggers� Comments

When you change an option by either checking or unchecking it, the checkbox textturns red. At the same time, the GO button turns red. This indicates that a change hastaken place, but is not yet reflected in the SQL script. Once you Click GO, the scriptrefreshes, implementing the options you’ve changed. The option text returns to itsoriginal black color and GO returns to its original gray color.

Copy Text to Clipboard

Select All Text

Copy Script to SQL Edit window

Page 277: Toad Users Guide

Chapter 9 Schema Browser 277

The GO button refreshes the script, updating any changes. If you’ve changedoptions, the GO button turns red until you click it, refreshing the screen. Your newscript is displayed, and the GO button return to its original gray color.

Refresh the Table Script

Page 278: Toad Users Guide

278

Grants

The Grants Tab lets you view existing table grants or assign or replace existingprivileges.

The Privileges button opens the Privileges window which lists the users.

The Privileges window, which is about to grant the UPDATE privilege onSCOTT's DEPT table to user DEMO.

Privileges

Page 279: Toad Users Guide

Chapter 9 Schema Browser 279

The dropdown button lists all the tables in your current schema. The selected tablename is displayed automatically.

Radio buttons let you choose between adding to existing privileges or replacingexisting privileges.

The user list, which is the list in the lower part of the window, lists all your schemasalphabetically and also lists the keyword PUBLIC at the bottom of the list. If anyroles are created it will also include the roles separated by the title "Roles". If youcannot see any roles, have your DBA Grant select on dba_roles to schema.

The user list is multi-select.

To Add or Replace Privileges1 Select the table from the dropdown if it’s not already displayed.

2 Select the Add to Any Existing Privileges or Replace Existing Privilegesradio button.

3 Select user(s) and/or role(s) from the user/role list.

4 Check the type of privileges you want to apply.

5 Click Apply.

6 A confirmation dialog will appear. Once you confirm by clicking OK, thePrivileges window remains. You need to click CANCEL to close the window.

7 The results grid displays the latest privileges.

Page 280: Toad Users Guide

280

Stats/Size

The Stats/Size tab displays numerous statistics and size information about theselected table.

The two display optionsShow StatsShow Size/Extentsare checked by default.

The Stats, such as TABLESPACE NAME and NUM ROWS are displayed in theupper window of the details panel and the Size/Extents information such as SIZE INBYTES and INITIAL EXTENTS are displayed in the lower window of the detailspanel.

The panel window columns are click and drag resizable, and a horizontal splitter isbetween them.

Stats/Size detail panel

Page 281: Toad Users Guide

Chapter 9 Schema Browser 281

Referential

The Referential tab displays a hierarchy of tables and how the selected table isreferenced by other tables and references other tables. This display is based on theexisting foreign key constraints from table to table.

Remember, “+” on the keyboard expands one branch of the hierarchy and<CTRL><SPACE> expands the whole tree. Pressing the asterisk key, "*", will fullyexpand the current node.

On each node of the hierarchy, there is a chain symbol for standard referential, and ascissors symbol if the reference is Cascade on Delete.

Circular references, such as EMPLOYEE.MANAGER_ID referencingEMPLOYEE.EMPLOYEE_ID are captured, so you cannot drill down in thehierarchy endlessly (for example, emp_id is referenced by manager_id, whichreferences emp_id, which references manager_id, and so on).

You can select an item in the list, press <F4> and get a popup window describing theobject in detail.

Page 282: Toad Users Guide

282

Used by

The Used By tab shows the objects that reference the selected table such as views,triggers, functions, procedures, and packages.

Here, the CUSTOMER table is selected.

This Used By tab shows that the CUSTOMER table is used by the Demo.Sales view.

Page 283: Toad Users Guide

Chapter 9 Schema Browser 283

Indexes

This section discusses the Indexes Tab.

Objects panelIn the list of indexes, "101" icons are BITMAP indexes, and "Yellow Square + RedTriangle + Blue Circle" icons indicate UNIQUE indexes (vs. non unique).

This copies the Create Index script of the selected index to the clipboard.

Use this function to rebuild a table index.

Rebuild Index

Create Script

Page 284: Toad Users Guide

284

Indexes need to be periodically rebuilt in order to improve query performance. Overtime, records are added to the end of tables and indexes, and other records aredeleted from the middle of tables and indexes. When you read the tables and indexes,the disk device has to traverse the chain up and back until your record is found.Rebuilding an index reorganizes the chain sequentially, substantially improvingquery performance.

The Rebuild Index window lets you change storage parameters, select a Paralleloption, and select a Recoverable option. You can click the SQL tab to see theresulting SQL syntax.

Page 285: Toad Users Guide

Chapter 9 Schema Browser 285

This collects statistics on the selected index so that COST based query optimizationcan be used. So, the optimizer can run better queries. A confirmation popup windowwill appear, select Yes, and the selected index will be analyzed.

This is disabled by default.

This will drop all indexes in the list. This will not drop indexes that have beenfiltered out of the list.

Refer to the "Dropping Objects" section of this chapter (page 246) for moreinformation about Drop All buttons.

This will drop the selected index.

Analyze Index

Drop Index

Drop All Indexes

Page 286: Toad Users Guide

286

Details PanelThe details panel displays information about the selected index including thecolumn, table name, table owner, parameters, and values. The horizontal splitterbetween the two panels can be moved up or down.

Page 287: Toad Users Guide

Chapter 9 Schema Browser 287

Procedures

In the list of PL/SQL Procedures, Functions, and Packages, a "Pink X" is for aPackage that contains one or more invalid (Red X) functions or procedures.

Page 288: Toad Users Guide

288

Objects Panel

This button lets you save the selected procedure to a file on your hard drive.

The Proc Edit button is enabled after you select a procedure. It opens a ProcedureEdit window for the Procedure that you’ve selected in the objects panel.

The Compile button compiles the selected procedure, function, or package.

The Compile All button compiles all procedures, functions, packages, and triggersfor the current schema.

The Procs Filter button displays a Browser Filter dialog for procedures.

Refer to the Filters discussion (page 248) for more about Filters.

Save to File

Proc Edit

Compile

Procs Filter

Compile All

Page 289: Toad Users Guide

Chapter 9 Schema Browser 289

The Compile Dependencies button will compile dependencies for the selectedprocedure. For example, if procedure A calls your procedure B, select procedure B,click the Compile Dependencies button and TOAD will recompile procedure A. Adialog asks you if you want to compile the dependencies on the selected procedure.Select Yes or No.

The Execute Procedure button executes the selected procedure, bringing up theExecute Procedure/Set Parameters window.

Use this window to view or modify the privileges of the selected procedure to otheruser schema accounts or roles.

The Privileges window is discussed in more detail in the Grants Section of thisTables Tab Section (page 278).

This drofiltered

The but

Refer to

D

Compile Dependencies

Execute Procedure

Privileges

rop All Procedures

ps all the procedures in the list. This will not drop procedures that have beenout of the list.

ton is disabled by default.

the "Dropping Objects" section (page 246) for more about Drop All.

Page 290: Toad Users Guide

290

This drops the selected procedure.

Drop Procedure

Page 291: Toad Users Guide

Chapter 9 Schema Browser 291

Details Panel

The details panel includes tabs for Arguments, Deps (Uses), Deps (Used by), Errors,and Grants.

The lower part of the details panel displays the source code for the selectedprocedure object.

The details panel for a selected Procedure.

Page 292: Toad Users Guide

292

Arguments

The Arguments tab displays information about the procedure arguments (if any) inthe upper part of the panel.

Deps (Uses) and Deps (Used By)

The Dependencies tabs (Uses and Used By) displays the dependencies in the upperpart of the panel. If there is a hierarchy of dependencies, the expand button will showthe hierarchy.

You can select an item in the Deps list, press <F4> and get a popup windowdescribing the object in detail.

Errors

The Errors tab displays the last errors that occurred when you tried to compile theselected procedure. If you click on an error, its location is highlighted in the scriptthat is displayed in the lower part of the details panel.

Grants

The Grants tab lists the Grants and shows the associated Privileges, whether or notthere is a "With Grant Option", and the Grantor. The tab contains two buttons.

This revokes all privileges that are in the list.

This revokes the selected privilege.

Revoke All

Revoke Privilege

Page 293: Toad Users Guide

Chapter 9 Schema Browser 293

Triggers

In the Triggers list, the icons to the left of the items represent the following:

� Red Circle with a slash indicates that the trigger is DISABLED

� Red Xindicates that the trigger is INVALID and needs recompiling

� White pageindicates that the trigger is VALID and ENABLED

Objects Panel

This button lets you save the selected trigger to a file on your hard drive.

This button takes the selected Trigger to the Procedure Editor ready for editing.

This button compiles the trigger that is selected in the objects panel.

Compile the Selected Trigger

Proc Edit (Trigger to Proc Editor)

Save to File

Page 294: Toad Users Guide

294

This button disables all triggers that are in the current schema.

This button enables all triggers in the current schema.

This button disables the trigger that is currently selected.

This button enables the currently selected trigger.

This button activates the Browser Filters for Triggers window.

This button drops the selected trigger.

This button drops all triggers in the list. This is a Drop All button and has to bemanually enabled on the Options window.

Refer to the "Dropping Objects" section, page 246, for more information about DropAll.

Disable All Triggers

Enable all Triggers

Disable the Current Trigger

Enable the current Trigger

Trigger Filter

Drop Trigger

Drop all Triggers

Page 295: Toad Users Guide

Chapter 9 Schema Browser 295

Details PanelThe details panel displays information about the selected trigger in the upper section:column, table, table owner, and usage. The lower section displays the SQL script forthe selected trigger. The horizontal dividing bar, also referred to as a splitter, is clickand drag moveable.

The trigger text is selectable via <CTRL>A, and can be copied to the clipboard via<CTRL>C.

Page 296: Toad Users Guide

296

Sequences

Sequences are basically counters that Oracle maintains. They have designatedstarting and stopping points.

The Sequences Tab displays information about the selected sequence in the detailspanel. You can check the cycle checkbox if you want the sequence cycled.

Page 297: Toad Users Guide

Chapter 9 Schema Browser 297

Objects Panel

This creates the Create Sequence script and copies it to a clipboard so that it can bepasted into a SQL Editor or another application.

This button opens the Create Sequence window where you can create a newsequence.

Sequence Privileges opens the privileges window for the selected sequence.

This creates a public synonym for the selected sequence.

When enabled, this drops all sequences in the current schema.

Refer to the "Dropping Objects" section, page 246, for more information about DropAll.

Create Script

Create New Sequence

Sequence Privileges

Add Public Synonym for this Sequence

Drop all Sequences, not enabled by default

Page 298: Toad Users Guide

298

Details PanelThe Modify button displays the Sequence Modify window where you can modifythe start value, the max value, the increment value, whether or not to cycle, and thenumber to cache settings. The Sequence Recreate button displays a similarwindow, however Recreate will first Drop the sequence, then Create it.

A sequence can either be ascending or descending. Oracle keeps sequences inmemory until it reaches its cache value (the number to cache).

Oracle preallocates the space and keeps the sequence in memory before caching.This lets TOAD and Oracle run faster.

If you are caching sequences, and the database crashes, you lose from whatever thesequence started with to wherever the sequence stopped. This might or might notmatter to you depending on why you are using the sequence. For example, if thesequence is for printed invoices where every number on the invoice is printed on asheet, then it is important for you to have every number in the sequence, and youdon’t want to cache anything.

An example of a situation where you might want to cache sequences, so that TOADcan run faster, is if you are using the sequences to generate unique id numbers forprimary keys, but you don’t need all the sequences.

Page 299: Toad Users Guide

Chapter 9 Schema Browser 299

Views

The Views tab displays details for the selected View item.

Page 300: Toad Users Guide

300

Objects Panel

Generates the create View script syntax and places it on the clipboard so that it canpasted into the SQL Editor or another application.

This opens the SQL Editor and pulls in the SQL Script of the selected View.

This button compiles the selected View.

This button compiles all the Views in the current schema.

This button displays the Privileges window for the selected View.

This button displays the Filter window for the selected View.

This button, when enabled, drops all Views in the current schema.

Refer to the "Dropping Objects" section of this chapter (page 246) for moreinformation about Drop All buttons.

Create Script

Show view in a SQL Editor

Compile

Compile All

View privileges

View Filter

Drop all Views

Page 301: Toad Users Guide

Chapter 9 Schema Browser 301

This drops the selected View.

Drop View

Page 302: Toad Users Guide

302

Details Panel

View

The View Tab includes a dropdown where you can select column comments, viewcomments, or no comments. Edit the comments, then click on a different column orview to save them.

An optional checkbox lets you either display or not display which columns of theview are updateable. This requires an extra query step, so it is an option.

The upper portion of the panel populates information about the selected view:column, data type, null (Y/N), and Updateable (if the checkbox is checked).

The lower part of the panel displays the SQL script for the selected view.

The horizontal dividing bar is click and drag moveable.

The view text is selectable via <CTRL>A and can be copied to the clipboard via<CTRL>C.

Page 303: Toad Users Guide

Chapter 9 Schema Browser 303

Data

The Data tab displays the data for the selected view, in table format. It includes afilter button, which pulls up the Table Sort window containing the Sort and Filtertabs. It has the single record view button, which pulls up the Single Record Viewwindow. It also includes the standard TOAD table navigation buttons for quicknavigation through the rows (or records).

The table navigation buttons let you quickly navigate through records.

Advance to the first record

Advance to the previous record

Advance to the next record

Advance to the last record

The single record view button activates the Single RecordView window which also allows for table navigation.

Page 304: Toad Users Guide

304

The Filter button pulls up the Table Sort window. For more information on the Table Sortdialog, see page 272.

Page 305: Toad Users Guide

Chapter 9 Schema Browser 305

Grants

The Grants tab displays Grant information for the selected view, granted to, type ofprivilege, whether or not there is a with grant option, and the grantor.

It also includes buttons for revoking all privileges or for revoking just the selectedprivilege.

Page 306: Toad Users Guide

306

Deps (Uses) and Deps (Used By)

The Dependencies tabs (Uses and Used By) displays the dependencies in the upperpart of the panel. If there is a hierarchy of dependencies, the expand button will showthe hierarchy.

You can select an item in the Deps list, press <F4> and get a popup windowdescribing the object in detail.

Page 307: Toad Users Guide

Chapter 9 Schema Browser 307

Filters

Synonyms

You can create synonyms for any object. Synonyms are useful for things likesecurity and ease of maintenance. Remember, synonyms basically point to theoriginal object.

Objects Panel

This puts a Create Synonym command for your script onto the clipboard so that youcan paste it into the SQL Editor or another application.

Filters let you filter out different types of synonyms.

Because the SYS/SYSTEM schemas contain a lot of synonyms, users like to filterthem out for easier navigation. So, the Show Public synonyms except those forobjects owned by SYS/SYSTEM is selected by default.

The symbol indicates a public synonym.

Create Script

Page 308: Toad Users Guide

308

In addition to the basic filter dropdown choices, the window also has radio buttonswhere you can choose the type of synonyms you want displayed. The checkboxes letyou show synonyms for tables, views, and/or stored procedures. A dropdown box isprovided for Object Owner choices.

This drops the selected synonym.

Drop Synonym

Page 309: Toad Users Guide

Chapter 9 Schema Browser 309

Details PanelWhen you click on a synonym from the object list, the details of the object thesynonym is pointing to displays in the details panel. So, you can see details aboutsynonyms pointing to tables, views, and stored procedures. Unknown Objects arelisted as UNKNOWN.

The details panel will also display tabs and details associated with the object. Forexample, if the object is a View the details panel will contain the same tabs theObject View Tab displays in the details panel (View, Data, Grants, Deps) and thesame associated details, options, and dialogs.

The details panel displays details of the object the synonym is pointing to.

Page 310: Toad Users Guide

310

Constraints

The Constraints tab displays the constraints in the objects panel and details about theconstraints including the type of constraint and the columns involved, in the detailspanel.

Objects Panel

This enables all constraints that are in the current schema.

This disables all constraints that are in the current schema.

This enables the selected constraint.

This disables the current constraint.

Enable all constraints

Disable all constraints

Enable the current constraint

Disable the current constraint

Page 311: Toad Users Guide

Chapter 9 Schema Browser 311

This pulls up a Browser Filter dialog window for constraints.

This drops the selected constraint.

Constraints filter

Drop Constraint

The Constraints Filter

Page 312: Toad Users Guide

312

When you disable constraints (either disable current or all), if any of the constraintsyou have selected to disable have dependencies, an Oracle error message will displaystating that you cannot disable constraints that have dependencies. If the constraintwas disabled, a red X will also appear next to your constraint in the objects list. Ifyou then enable the constraint, the red X will disappear.

Page 313: Toad Users Guide

Chapter 9 Schema Browser 313

Details PanelThe details panel provides information about the selected constraint including itstype, status, table and owner.

Page 314: Toad Users Guide

314

Db Links

The Db Links lists all possible links from the database you are using. Links can bepublic (used by all schemas) or private (used only by the schema that created it).

Db Links are used in queries at the end of each table or view name.

Objects Panel

This displays the Create Database Link window where you can fill in theinformation to create a database link. The dropdown menu lets you select from thelist of databases to connect to. After the information boxes are filled in, select theExecute button to create the database link.

Create new database link

Public links in the list have the symbol next to them.

Page 315: Toad Users Guide

Chapter 9 Schema Browser 315

This drops the selected database link.

Details PanelThe details panel lists the host, user name, and the date and time the link was created,for the selected Db link from the object list.

Drop Db link

Page 316: Toad Users Guide

316

JAVATOAD includes a JAVA tab for Oracle 8i databases. The JAVA tab does not have adetails panel. The two buttons it has in its object list are Compile and Drop.

Page 317: Toad Users Guide

Chapter 9 Schema Browser 317

Schema Browser Tasks

This section will take you step-by-step through various tasks that you might want toperform with the Schema Browser.

To copy table or view column names to the clipboardYou can copy the column names from the list on the Tables/Columns tab or theViews/Columns tab via multi-select list and copy <CTRL>C.

From Tables > Columns

1 Click the Column you want to copy. To select more than one column press<CTRL> while clicking the columns you wish to select. To select a continuousblock of columns select the starting point, press <SHIFT> and click on theending part of the blocked selection.

2 Press <CTRL>C or select Edit > Copy from the menu.

The selection is copied to the clipboard.

In this example, the following selection is copied to the clipboard

CUSTOMER_ID, CITY, ZIP_CODE,

Page 318: Toad Users Guide

318

To export table data in a certain orderIn the Data Export window, which is accessible ONLY from the Schema Browserwindow > Tables tab > Export Data button, you can export table data to either afile or the clipboard. If you want to filter out only certain records, enter the WHEREclause in the where textbox on the Options tab.

Here's a handy trick that TOAD performs. If you further want to sort the data, simplyadd an “ORDER BY” clause after the “WHERE” clause. TOAD adds the entirestring onto the end of the SQL and executes it.

Page 319: Toad Users Guide

Chapter 9 Schema Browser 319

To filter out schemas that do not contain objects from the schemadropdown listIf you have a database where only a few schemas contain objects, e.g., tables, views,etc., and all other schemas are used as end-user logins, then go to the View >Options > Schema Browser node, and check Only show users that own objects indropdown lists.

In this example the OPS$ accounts (and other schemas that do not own any objects)are filtered out in the list on the right.

Page 320: Toad Users Guide

320

To filter out objects that you do not want to see from the object listsUse the filter buttons on the various object tabs to include or exclude certain objects.The filters make object lists more manageable.

Filters are discussed in detail in the Tables section of this chapter, page 260.

To Show/Hide Object TabsRight-click over the object tabs list and check which ones you want to see.

Refer to the Right-Click Menus section of this chapter, page 235, for moreinformation about the Right-Click Menu.

Page 321: Toad Users Guide

Other TOAD Options and Features

The windows covered in the previous chapters of this manual are: Server Login,SQL Editor, Procedure Editor, PL/SQL Debugger, and Schema Browser. Thissection will highlight some selected options and features found in other TOADwindows.

Page 322: Toad Users Guide

322

SQL ModelerThe SQL Modeler dialog lets you quickly create the framework of a Select, Insert,Update, or Delete statement. You can select Tables, Views, or Synonyms, joincolumns, select columns, and create the desired type of statement.

Two ways to invoke the SQL Modeler

� Click the Database > SQL Modeler menu item.

� Click the Open a new SQL Modeler button that is on the main toolbar.

The SQL Modeler is comprised of three main sections:

� Table Model Area

The Table Model Area lets you graphically lay out a query. Simply double-click(or drag and drop) an item from the Table Selector list and its associated tableobject appears in the Table Model Area.

To maximize the model viewing area, press F2 or right-click in the model andselect Full Screen Model from the Right-Click Menu.

� Table Selector Area

This is where the tables are listed for the selected schema. A dropdown list letsyou select a schema.

� Generated SQL Query

After you lay out your query, click the Generated Query tab and the resultingquery will display. Other tabs in the window are Criteria, Query Results, andExplain Plan.

Open a new SQL Modeler

Page 323: Toad Users Guide

Chapter 10 Other TOAD Options and Features 323

The alias comes from ALIASES.TXT. See page 67 for details about setting uptable aliases. If the selected table does not have an entry in ALIASES.TXT, thenthe first three characters of the table name are used to generate the alias, whichmight not always be unique. For example, the aliases for ALL_OBJECTS andALL_TABLES are both going to be ALL. You can edit the alias as desired tomake it unique, or change it to something more meaningful. If the table name iseight characters or less in length, the entire table name is used as the table alias.

Page 324: Toad Users Guide

324

Table Selector List - Here, the Department table isselected from the TOAD schema.

The selected tables (Department and Employee) display in the table model area and the GeneratedQuery displays the resulting SQL script.

Page 325: Toad Users Guide

Chapter 10 Other TOAD Options and Features 325

With the SQL Modeler you can:

� Drag and Drop (or double-click) Tables, Views, or Synonyms from the TableSelector to the modeling area.

� Drag and Drop columns from one table to another to create joins between thetables.

� Double-click a column to select or deselect it.

� Save the model to disk.

� Click the Generated Query tab to view the generated SQL query, and click theSQL toolbar button to copy the query to the SQL Edit window.

Page 326: Toad Users Guide

326

Toolbar Buttons

Create New Model

Open Model from

Save Model to Disk As...

Edit Current Model Info

Add Calculated Fields

Generate a Select Statement has dropdown to create different types of queries

Execute SQL Statement

Show Explain Plan

w

Save to Disk

View SQL in SQL Edit Windo

Hide Table List

Page 327: Toad Users Guide

Chapter 10 Other TOAD Options and Features 327

Model Area

This is the area to visually join or manipulate the Tables, Views, or Synonyms. Dragthe table header and drop it to improve the readability of the model.

You can establish your own joins by dragging and dropping a column from one tableto another table column. Once the line is drawn, you can double-click the line toadjust its properties such as Inner Join vs. Outer Join, or Join Test, e.g., equal (=),less then (<), greater then (>), etc.

If no table columns are selected, then all columns will be included in the query. Ifyou want only certain columns, double-click each desired column. A plus symbol (+)will be displayed to the left of each selected column. The selected columninformation will appear in the Criteria grid below.

Model Area Right-Click Menu

Right-clicking over the model displays this popup menu:

Copy Model Image to Clipboard

Copies a bitmap image of the model to the Windows Clipboard

Tables|Visibility

Displays a Tables Visibility window with checkboxes next to a list of your tablesthat are in the model. You can check/uncheck the individual tables to show/hidethem.

Tables|Calculated Fields

Adds calculated fields based on other table columns

Page 328: Toad Users Guide

328

Show|Join Text

Displays the column names that comprise the joins

Show|Zoom on Table

Pulls up a Choose a table to focus menu. Double-click on the table you wish tofocus on, and the model scrolls until the table comes into center view.

Show|Adjust Model Origin

Adjusts the upper left object to the upper left of the window

Show|Virtual Space Size

Brings up a Model Virtual Space dialog that displays the horizontal and verticalmodel space, which you can alter.

Show|Primary Key

Shows or hides the Table Primary Keys as "(PK)" next to each PK col

Show|Show Field Type

Shows or hides the data type of each table column

SQL|Distinct Mode

Adds "DISTINCT" to the query to return only unique rows

SQL|Global Where

Adds a WHERE clause to the query in addition to the column conditions from theCriteria tab

Page 329: Toad Users Guide

Chapter 10 Other TOAD Options and Features 329

SQL|Global Having

Adds a HAVING clause to the query in addition to the column conditions from theCriteria tab

SQL|Query Variables

Displays the Variables and Constants window where you can add and editvariables

Auto Join All

Automatically joins all tables based on existing DDL Foreign Key Constraints

Full Screen Model

Temporarily hides the Table Select list and Results tab

Right-Click Table Object Menu

Right-clicking over each Table object in the model displays this popup menu:

Logical Field Names

Sets logical column names

Page 330: Toad Users Guide

330

Show Schema Name in SQL

Shows or Hides the schema name before each table in the generated query

Set Alias

Sets the Table alias

Auto Join

Automatically joins this table to others based on existing DDL Foreign KeyConstraints

Remove Table

Permanently removes this table from the model. See “Tables/Visibility” (above) totemporarily remove a table from the model.

Select All

Selects all Columns in the Table

Unselect All

Unselects all Columns in the Table

Invert Selection

Selects columns that were unselected and vice versa

Visual Properties

Brings up the Visual Object Properties dialog to adjust the table visual propertiessuch as font, color, and alignment

Page 331: Toad Users Guide

Chapter 10 Other TOAD Options and Features 331

Hide

Temporarily hides this Table from the model. To unhide the table, right-click overempty model space and select the Tables > Visibility menu item.

Page 332: Toad Users Guide

332

Results Grid

The Results Grid contains four tabs: Criteria, Generated Query, Query Results, andExplain Plan.

Criteria tabIf individual columns are selected, they will be displayed in the Criteria grid.

You can edit many of the column properties in the Criteria grid. "Table" and"Schema" are not editable here. Double-clicking on the following Criteria columnshas the following effects.

Double-click on:

Sort to select this column as Ascending sort, Descending sort, or no sort.

Here, the Manager (MGR) andSalary (SAL) columns wereselected from the Employee(EMP) table. So, the + symbolappears at the left of MGR andSAL and information on theselected columns displays in theCriteria grid.

Page 333: Toad Users Guide

Chapter 10 Other TOAD Options and Features 333

Condition to bring up the Input the WHERE Definition dialog, where you can seta column equal to a constant value or another column value. To remove the WHEREdefinition, bring up the dialog and click the Clear button.

Or to enter another WHERE criteria, which will be OR'd together with the aboveWHERE criteria. If you want to AND multiple column criteria together, then go tothe expert mode from the Input the WHERE Definition dialog.

Aggregate Function to select an aggregate column function, such as Average,Count, Max, Min, or Sum.

Field Name to enter a different logical column name.

Visible to toggle whether or not this column is returned in the column list (Show orNot Show).

Group to select this as a GROUP BY column. A number within parenthesesindicates the order of the columns in the GROUP BY clause.

Group Condition to bring up the "Input the GROUP BY Definition" window toenter a GROUP BY condition.

If you want to change the table alias, right-click over the table in the model andselect the Set Alias menu item.

To rearrange the order of the columns, click the column headers, then drag and dropthem left or right.

Page 334: Toad Users Guide

334

Right-clicking over the Criteria grid will display this popup menu:

Suppress Current Column

Removes this column from the query, which also removes the plus “+” from thecolumn in the model

Best Fit (All Columns)

Sets the column width of the Criteria grid to show all text

Default Width (All Columns)

Sets the column width of the Criteria grid to the default width

Copy Query Grid Image to Clipboard

Copies the Criteria grid to the clipboard

Page 335: Toad Users Guide

Chapter 10 Other TOAD Options and Features 335

Generated Query tabThis tab lists the automatically generated SQL statement. Any changes made to themodel or column Criteria will automatically regenerate this SQL statement.

You can copy the query to the clipboard by selecting it and pressing <CTRL>C orright-click and selecting Copy from the popup menu.

You can also copy the query directly to the SQL Edit window by clicking the SQLbutton in the SQL Modeler toolbar.

You cannot directly edit the SQL on the Generated Query tab dialog.

The query is syntax highlighted using the same editor settings from the SQL Edit orStored Procedure Edit window.

Page 336: Toad Users Guide

336

Query Results tabThis grid displays the results of executing the generated query. Insert, Update, andDelete queries can only be executed in the SQL Edit window.

Page 337: Toad Users Guide

Chapter 10 Other TOAD Options and Features 337

Right-clicking over the Query Results grid displays this popup menu:

Print Grid

Prints a hardcopy report of the data

Save As

Saves the data to Clipboard or File (same dialog as Grid Save As from the SQL Editwindow’s SQL Results Grid, see page 107 for details)

Export to Flat File

Saves the data as a Flat File (same dialog as Flat File Export, see page 110 fordetails)

Find Data

Finds data in the grid (same dialog as Find Data, see page 112 for details)

Record Count

Displays the number of records in the grid

Row Height|Single|Double|Triple

Sets the grid row height

Page 338: Toad Users Guide

338

Explain Plan tabClick the Explain Plan button on the SQL Modeler toolbar to generate and displayan Explain Plan output for the generated SQL statement.

Right-clicking over the Explain Plan window reveals this popup menu

Copy to Clipboard

Copies the Explain Plan statement (in text mode) to the Clipboard

Optimizer Mode

Allows you to select the query optimizer mode for subsequent statements fromChoose, Default, Rule, First Rows, or All Rows.

Page 339: Toad Users Guide

Chapter 10 Other TOAD Options and Features 339

SQL Modeler OptionsSQL Modeler options can be set or changed in the TOAD Options window. Selectthe View > Options menu item to invoke the TOAD Options dialog for the SQLModeler. Click the expand button next to the SQL Modeler option and the Visual,General, and Functions categories will display.

Visual

Select an element from the list which includes

� Table Title

� Table Data

� Table Border

� Field Type Font

� Calculated Field Font

� Inner Join

� Outer Join

Click over the desired color box to select a color for the element. If appropriate,right-click over the color box to select a background color for the selected item.

A preview of the Table object with its new colors is displayed in the previewwindow below.

You can also select fonts for Table Title or Table Data then click the font buttonwhich has the picture of the three A's in different fonts.

Title Alignment has radio buttons that let you align the title either left, center, orright.

You can click the Rounded Shapes checkbox to give your table squares roundedcorners.

You can adjust the thickness of the table object border by selecting a value from 1 to10 on the Border Width selector. You can also click and drag the border arrow upand down the 1 to 10 scale to select the desired width. The preview pane shows theresult.

If you want to discard your custom settings and return to the default settings for theSQL Modeler > Visual options, click the Revert to Default button.

Page 340: Toad Users Guide

340

General

Automatic AutoJoin

Default – Checked

When checked, this feature will automatically check foreign key constraints and jointables that are dropped into a model with other tables. If the option is unchecked,then you can manually join tables with the table popup menu.

Default "Show Schema Name" On

When selected, this feature will always precede the table name with the schemaname (i.e., myschema.mytable) in the generated SQL. Schema names are alwaysused if the table belongs to a different login.

Revert to Default button

Click this button to discard your customized options and revert to the default settingsfor the SQL Modeler > General Options.

Functions

This is the list of functions displayed in the Field Definitions dialogs.

To add a function from the list, select it and click the <Remove> button.

Revert to Default

This will discard the customized setting and revert to the default settings for the SQLModeler > Functions Options.

Refer to TOAD HELP for more information about the many options, functions, andwindows that are in the SQL Modeler.

Page 341: Toad Users Guide

Chapter 10 Other TOAD Options and Features 341

Object Search

You can open the Object Search window by either clicking the toolbar button or byselecting the Database > Object Search menu item.

Object Search searches all database object names, table column names, index columnnames, constraint column names, trigger column names, and procedure source codefor a keyword or phrase. Each of these items can be searched or excluded from thesearch via checkbox options.

Many of the capabilities of the Object Search window can be found on the Filters forthe Schema Browser window allowing the results of the search to be viewed in abrowser.

You can search across All Users, including or excluding SYS and SYSTEMschemas, or you can search just one schema, by selecting the schema in theSchemas/Owners dropdown list. To search across all schemas, pick the first entry inthe Schemas/Owners dropdown list, entitled, “* ALL USERS.”

The Object Search button is on the main toolbar.

This button, on the Object Search window, lets you change the active sessionfor the window.

In the Procedure Editor chapter, a C_TO_FAHRENHEIT procedure was created. Here, asearch in the appropriate schema for C_TO finds the C_TO_FAHRENHEIT function andsource.

Page 342: Toad Users Guide

342

To use the Object Search window1 Select the Schema/Owner from the dropdown.

2 Check or uncheck the Exclude Sys and System checkbox, as appropriate.

3 Type the search word(s) in the Search for box.

4 Check the appropriate Object Search checkboxes and choose the type of filterfrom the dropdown box. You have a choice of: Text occurs anywhere, Startswith, or Exact match.

5 Check the appropriate Source Search checkboxes. You can specify casesensitive if you want to even filter your search further.

6 Click the Search button to begin the search.

7 The results will display in the results grid. If no matches are found, the resultsgrid will be empty.

8 In the results grid you can double-click on a TABLE, VIEW, or PROCEDURE,and a popup details window displays about the object.

Page 343: Toad Users Guide

Chapter 10 Other TOAD Options and Features 343

DDL Reports

Two ways to invoke DDL Reports.

1 Click the Reports button on the main window.

2 Click the View > Reports menu item.

Use this function to print detailed DDL reports of a schema. This prints theproperties of the selected table(s).

The Reports tab includes a schema dropdown selection and lists numerous optionsof what you wish to include. The Tables Selection tab allows you to select whichtable(s) to include. The Views tab lets you select which available view(s) to include.The Options tab includes options such as printing each table/view on a new page.Printer Setup provides additional printing options such as Landscape and Portraitradio buttons, printer selection, and paper size.

Indexes and Constraints reports have not been implemented so their associatedbuttons are disabled.

The Reports button, on the main window, activates the TOAD Reports window.

Page 344: Toad Users Guide

344

The TOAD Reports window

Page 345: Toad Users Guide

Chapter 10 Other TOAD Options and Features 345

Master/Detail record browser

The Master/Detail record browser is based on foreign key constraints. It lets youbrowse or edit table data in a database, where the tables are linked by foreign keys.This is like a database setup from an Entity/Relationship diagram, where one table'sobjects are related to another table's objects by a linking field or fields.

For example, you could start with the DEPARTMENT table, pick "EMPLOYEE"from the related tables dropdown list, select a department record, and the employeerecords display only for that particular department.

You could further drill down in the EMPLOYEE table to show employees managedby the current manager employee, by selecting "EMPLOYEE" again from theEmployee's related tables dropdown list. Selecting a manager employee record willnow automatically display the employees managed by that manager. This is knownas a circular table reference, where employee.manager_id is related toemployee.employee_id.

There is currently a static limit of five related tables.

There is also a right-click mouse menu (over the grids) for Print Grid, Save As, CopyRow, and Record Count.

Page 346: Toad Users Guide

346

To Use the Master/Detail record browser1 Go to Database > Master Detail Browser.

2 Pick a Schema from the dropdown list.

3 Pick a Table from the dropdown list.

4 Go to the Related tables dropdown and select a table.

5 Now you can select any item from the main table and the related table will bepopulated with the associated details.

Here, the DEPT table is selected from the SCOTT schema. Then the EMP table is selected from theRelated Tables dropdown. NEW YORK was selected from the main table and only the New YorkEmployees are displayed in the EMP grid.

Page 347: Toad Users Guide

Chapter 10 Other TOAD Options and Features 347

PrivilegesThe Privileges window is where users are created, and role and user privileges can beviewed or altered.

You get to this dialog via the Database > Privileges menu item.

If you do not have DBA privileges, you cannot access this window and you will get a"ORA-00942 Table or View does not exist" error if you try to open this dialog.

With the Privileges window, Database Administrators can view:

1 Users

(a). When the user account was created, their tablespace and profile settings

(b). Which Roles they have granted to them

(c). What Object Privileges they have granted to them

(d). What System Privileges they have (e.g., SELECT ANY TABLE)

2 Roles

(a). System Privileges

(b). Users with the Role

(c). Object Privileges

(d). Granted Roles

Page 348: Toad Users Guide

348

3 System Privileges

(a). Roles with the Privilege

(b). Users with the Privilege

From the Users tab you can:

1 Create a script to recreate the selected user, which includes the "Create User"command, and all the necessary "Grant" commands to recreate the user. Thescript is copied to the clipboard.

2 Create a new user, which will open the Create User window, where you canselect the username, password, tablespace, profile settings, system privileges,and roles.

3 Modify the selected user, by changing user settings, or adding more systemprivileges and/or roles.

4 Create a new user as an exact copy of the selected user.

5 Drop an existing user.

6 Revoke a single or multiple Role, Object Privilege, or System Privilege from auser.

7 Change a user’s role from DEFAULT to not DEFAULT or vice versa.

From the Roles tab you can:

1 Drop a role.

2 Revoke a single or multiple System Privileges from a role.

3 Revoke a user from the selected role.

4 Revoke a single or multiple object privilege from a role.

5 Revoke a role from a role.

Page 349: Toad Users Guide

Chapter 10 Other TOAD Options and Features 349

Rebuild Table

Use this function to rebuild a table, optionally dropping column(s), and/or renamingcolumn(s). This will also coalesce the space occupied by the table.

You get to this window via the Database > Rebuild Table menu item.

This window will create a complete script to rebuild a table, after which you canfurther edit to customize, if desired.

The Rebuild Tables window

Page 350: Toad Users Guide

350

To Rebuild a Table1 Logon as the table owner, because you cannot change owners in the Rebuild

Table window.

2 Click the Database > Rebuild Table menu item.

3 Select a table to rebuild from the Tables dropdown list.

4 On the Options tab, select the storage parameters. You can either use theoriginal storage parameters or use the current table size as the initial extent,which will combine all extents together into one extent, resulting in faster diskperformance.

5 On the Columns tab, double-click a column on the upper list to exclude it (dropit) from the table. To rename a column, click to select it (from the upper list),wait until after the mouse double-click time, then click it again. Enter the newname for the column.

6 Click the SQL tab. The rebuild table script will be constructed and displayed.Now you can either save the script to a file, or copy it to the clipboard. Toexecute the script, copy it, paste it into the SQL Edit window, and execute it.

Indexes owned by different schemas are not rebuilt in the Rebuild Table process.

Page 351: Toad Users Guide

Chapter 10 Other TOAD Options and Features 351

TOAD Security

TOAD includes a security feature. So, you can restrict TOAD users from havingaccess to specific TOAD features.

To set up security1 Load the \TEMPS\TOADSECURITY.SQL script to create two tables in the

TOAD schema: TOAD_FEATURES and TOAD_SECURITY. These areREQUIRED to be in the TOAD schema—they can’t simply be in anotherschema with synonyms pointing back.

TOAD_FEATURES is a two column table. NAME is the keyword that TOADresponds to in order to enable or disable functionality. DO NOT change the datain the NAME column. DESCR is the description of the specific TOAD featureto enable or disable. Feel free to edit the descriptions of the features, if you wish.If there is some ambiguity about a function, then the description should indicatewhere that function exists in TOAD. "SB" is for Schema Browser.

TOAD_SECURITY is a two column table of USER and FEATURE, fromTOAD_FEATURES.NAME. If there is not a record in TOAD_SECURITY forthe given user and function, then the user cannot run that function.

2 Run TOAD, login as the TOAD schema, select the Database > TOAD Securitymenu item to bring up the TOAD Features Security window. Select the user orrole, then select the features you want to grant to that user. All other featureswill be disabled from this user. You can also delete records from theTOAD_SECURITY table directly, in order to remove functions from certainusers. Since other non-DBA users only have SELECT privileges to theTOAD_SECURITY table, they cannot make changes to the security.

Page 352: Toad Users Guide

352

3 Click the Grant SELECT button so that the user or role can see theTOAD.TOAD_SECURITY table.

If the user cannot "see" the TOAD_SECURITY table (i.e., they do not haveSELECT access granted to them), then they have FULL access to all TOADfeatures.

If the user has SELECT privileges on the TOAD_SECURITY table, then thesecurity is in effect.

Menus are disabled and enabled from top down. For example, if the entire Createmenu is disabled for a user by a CREATE MENU record in the security table, thenall items on the Create menu will be disabled. If there is also a CREATE INDEXrecord in the security table, then that individual menu item will be re-enabled.

Not all buttons, menus, or functions in TOAD are contained within this securityscheme. If you need to restrict other functionality, please let us know.

You can also create collections of TOAD features using existing Oracle roles. Grantthe features to a role, e.g., DEVELOPER_ROLE, grant the role to the end user(s),then those TOAD users will get the collections of TOAD functionality withouthaving to set up the same list of TOAD features for multiple users.

NOTE: TOAD security is not enforced if the user has the DBA role.

Page 353: Toad Users Guide

Chapter 10 Other TOAD Options and Features 353

Example #1To disable only the Kill Session feature from user SCOTTNote that users can Kill Oracle Sessions in two windows: Tuning > Server Stats >Locks tab has a Kill Session button, and View > Kill/Trace Session has a KillSession button.

1 Start TOAD, login as user TOAD or a user with the DBA role, go to theDatabase >TOAD Security window.

2 Select "SCOTT" from the Schema/Users dropdown list.

The Tuning > Server Stats > Locks tab window contains a Kill Session button,which can be enabled or disabled for different users through TOAD Security.

Page 354: Toad Users Guide

354

3 Confirm that SCOTT has Select privilege to the TOAD.TOAD_SECURITYtable. If the SELECT button caption is "Grant SELECT" then click it to executethe grant. If the button caption is "Revoke SELECT" then the grant alreadyexists.

4 Copy all features to the "Granted Features" list. Select "View Menu, Trace/KillWindow" and "Kill Session Buttons" from the "Granted Features" list. Use click<CTRL> click to select multiple items in the list. Click the Remove One buttonto move these two features back to the Available Features list. You can also usedrag and drop between the two lists.

Here, Kill Session Buttons and View Menu/Trace/Kill Window were selected from the Grantedfeatures list and moved with a click of the left arrow to the available features list.

Page 355: Toad Users Guide

Chapter 10 Other TOAD Options and Features 355

5 Click the EXECUTE button. TOAD will "grant select on toad.toad_security toscott" and write these records into the TOAD_SECURITY table:

USER_NAME FEATURESCOTT ADD COLUMNSCOTT ADD CONSTRAINTSCOTT ADD INDEXSCOTT ALTER CONSTRAINTSCOTT ANALYZESCOTT ANALYZE ALL TABLESSCOTT COMPILE DEPSSCOTT COMPILE SCHEMASCOTT CREATE INDEXSCOTT CREATE LINKSCOTT CREATE MENUSCOTT DROP INDEXSCOTT DROP TABLESCOTT DROP TABLESSCOTT IMPORT MENUSCOTT REBUILD INDEXSCOTT REBUILD TABLESCOTT SCHEMA BROWSERSCOTT SESSION STATSSCOTT TABLE PRIVSSCOTT TOAD SECURITYSCOTT TUNING MENUSCOTT VIEW EXTENTSSCOTT VIEW MENUSCOTT VIEW TABLESPACE

6 Have user SCOTT logoff/logon to TOAD. Their View|Kill/Trace Session menuitem is now disabled, and their Kill Session button on their Tuning > ServerStats > Locks tab is also disabled, thus the Kill Session functionality has beenremoved from user SCOTT.

Page 356: Toad Users Guide

356

Example #2To set up a list of different kinds of TOAD features and then grant the listto select groups of users1 Start TOAD, login as user TOAD or a user with the DBA role, go to the

Database > TOAD Security window.

2 Select DEVELOPER _ROLE from the Schema/Users dropdown list. Theseare standard Oracle roles. Have your DBA create the roles if necessary. DONOT use the DBA role. When TOAD starts, if the user has the DBA role, thenthat overrides everything else, including security.

3 Confirm that DEVELOPER_ROLE has Select priv to theTOAD.TOAD_SECURITY table. If the SELECT button caption is “GrantSELECT" then click it to execute the grant. If the button caption is "RevokeSELECT" then the grant already exists.

4 Copy the desired features to the "Granted Features" list.

5 Click the EXECUTE button. TOAD will "grant select on toad.toad_security todeveloper_role" and write the selected records into the TOAD_SECURITYtable:

USER_NAME FEATUREDEVELOPER_ROLE ADD COLUMNDEVELOPER_ROLE ADD CONSTRAINTDEVELOPER_ROLE ADD INDEXDEVELOPER_ROLE ALTER CONSTRAINTDEVELOPER_ROLE ANALYZEDEVELOPER_ROLE COMPILE DEPSDEVELOPER_ROLE COMPILE SCHEMADEVELOPER_ROLE CREATE INDEXDEVELOPER_ROLE CREATE MENUDEVELOPER_ROLE DROP INDEXDEVELOPER_ROLE DROP TABLEDEVELOPER_ROLE DROP TABLESDEVELOPER_ROLE IMPORT MENUDEVELOPER_ROLE REBUILD INDEXDEVELOPER_ROLE REBUILD TABLE

Page 357: Toad Users Guide

Chapter 10 Other TOAD Options and Features 357

6 Confirm that the Oracle Role has been granted to the user: [grant developer_roleto scott].

7 Have user SCOTT logoff/logon to TOAD. Their TOAD features should belimited as specified.

8 Repeat these steps for setting up features for the other desired roles, e.g.,TUNER_ROLE, MAINTENANCE_ROLE, etc.

Page 358: Toad Users Guide

358

View MenuThe Main View Menu contains the following menu items:

� Browser Filters� Constraints� Dependencies� Explain Plan� Session Info� Kill/Trace Session� Extents� TableSpaces� Oracle Parameters� Source Control� Check-In/Check-Out� Schema Differences� Table Duplicates� Reports� Oracle Users List� Options� PL/Formatter Options

(enabled if RevealNet PL/Formatter is installed)

Page 359: Toad Users Guide

Chapter 10 Other TOAD Options and Features 359

Options Menu

The View > Options menu contains numerous options. Many of these options havealready been discussed. The options in the menu are:

� General

� Oracle

� SQL Editor

� Data Grids

� Procedure Editor

� Editors

� StartUp

� Schema Browser

� Files

� Debugging

� Object Browser

� Source Control

� Printing

� SQL Modeler

This section will briefly cover the Options > General, Oracle, Startup, Files,Source Control, Printing, and SQL Modeler. Refer to TOAD Help for informationon the other TOAD Options.

Page 360: Toad Users Guide

360

General OptionsShow USER@DATABASE in window captions

Default – Checked

If checked, TOAD will show the schema username, the "@" symbol, and thedatabase alias in the window caption on the applicable windows. If unchecked,TOAD will only show the schema username.

Show details following Oracle connection (and Oracle DLL load) features

Default – Checked

If checked, this option displays a message box with details about the TOAD toOracle connection handshaking.

Confirm before closing TOAD

Default – Unchecked

If checked, TOAD will prompt you with YES or NO buttons when you either clickthe control box, close the TOAD application button, or select the menu item File >Exit.

Allow multiple copies of TOAD to be loaded

Default – Unchecked

If checked, will permit multiple instances of the TOAD application to be loaded.

Display dropdown menus on ChangeSession buttons

Default – Checked

If checked, will display the dropdown arrow on the Load from File or Load Sourcefrom Database toolbar buttons so that you can pick the last 10 items, and willdisplay the dropdown arrow on the change session buttons.

Show Splash Screen at startup

Default – Checked

Page 361: Toad Users Guide

Chapter 10 Other TOAD Options and Features 361

If checked, the splash screen will display when you start TOAD.

Use the old style clipboard keys in the Edit menu

Default – Unchecked

If checked, will use the old style clipboard keys in the Edit menu.

Use locale settings (date format, decimal, char, etc.)

Default – Unchecked

If checked, TOAD will use the locale settings.

Page 362: Toad Users Guide

362

Oracle OptionsCommit automatically after every statement

Default – Unchecked

This is a session level setting that, when checked, forces an automatic COMMIT tobe sent following every statement.

Prompt for Commit when closing TOAD if AutoCommit is disabled

Default – Checked

When Auto Commit is disabled, TOAD asks whether to perform a commit when theprogram is terminating. If this option is unchecked, TOAD will NOT prompt and anyuncommitted statements will be unsaved.

Oracle will perform a commit following any DDL modifications.

Save passwords for Oracle connections

Default – Unchecked

Normally, only the schema and database are saved to the TOAD.INI file for eachnew Oracle connection. When checked, this option saves the passwords as well. Besure you work in a secure environment where your TOAD.INI file will not fall intothe wrong hands.

Encrypt saved passwords

Default – Unchecked

If checked, will encrypt the saved passwords so that editing TOAD.INI will notreveal what the passwords actually are.

Save previous Explain Plan results (requires TOAD tables)

Default – Unchecked

If checked, will save the explain plan outputs in the TOAD tables, viewable in theView > Explain Plan window.

Page 363: Toad Users Guide

Chapter 10 Other TOAD Options and Features 363

Use \TEMPS\EXPLAN.SQL to fetch Explain Plan results

Default – Unchecked

If checked, TOAD will read the file EXPLAIN.SQL, which you can customize via atext editor, and TOAD will use that query to fetch and display the Explain Planresults.

Explain Plan Table Name textbox

Default – TOAD_PLAN_TABLE

This is the table name that you want TOAD to use when saving explain plan results.Use TOADPREP.SQL or NOTOAD.SQL to set this up. Refer to the InstallationNotes topic in TOAD Help for more information on installation.

User name for Explain Plan textbox

Default – the windows logon name

This is the username that will be used when writing out and fetching explain plandata.

Full path of SQL*Plus textbox

Default- Blank

This is the drive letter, path, and folder location of the SQL*Plus executable. Ifblank, TOAD will use the ORACLE_HOME\bin folder to find the SQL*Plusexecutable.

Use a separate connection when TOAD itself is generating transactions

Default – Unchecked

If checked, when TOAD is putting data into the TOAD temp tables or explain planfunction, this setting will force TOAD to use a separate connection.

Page 364: Toad Users Guide

364

Load tablenames from database at time of Login for each connection

Default – Unchecked

TOAD caches tablenames and only queries tablenames the first time they are neededper Oracle session. If checked, this option will cause TOAD to requery Oracle fortablenames every time they are needed to fill a list of tablenames. If the table list isalready cached, the list will override the global browser filter for tables, when theSchema Browser window is opened.

Refresh tablenames list on every display

Default – Unchecked

Throughout TOAD, there are lists that display the tablenames for the current schema.Usually, once TOAD reads the list, the list is cached to speed all future displays. Ifchecked, this option forces a refresh before every display. Note that table name listsare affected by the Browser Filters.

Display size of extents dropdown list

Default – Kilobytes (KB)

This lets you select the table storage extent size in either Bytes, Kilobytes (KB), orMegabytes (MB).

OCI Array Buffer size number box

Default – 25

This lets you enter a number for the OCI Array Buffer size.

Optimizer mode for DDL queries

Default – "Default"

This lets you select the best optimizer hint for the DDL queries that TOAD executes.You can choose from the following:� Default� /* + CHOOSE */� /* + RULE */� /* + FIRST_ROWS */

Page 365: Toad Users Guide

Chapter 10 Other TOAD Options and Features 365

Startup OptionsPlay TOAD Wave File at StartupDefault – CheckedIf checked, will croak when TOAD is starting. If you are having sound cardproblems, uncheck this option.

Use a 3D Main Form (MDI parent inner client area)Default – CheckedIf checked, TOAD paints the main form in three dimensional gray/black lines.

Decimal Character (affects printing and number conversion) textboxDefault – "." (period)This will be the character that is used as a decimal.

Start Up WindowsDefault – "SQL Editor"You can select which MDI child window(s) comes up when TOAD starts: SQLEditor, Procedure Editor, and/or Schema Browser.

File to AutoLoad on Startup textboxDefault – Blank (display no file)This file will automatically be loaded into the first SQL Edit Window that displaysfollowing a database Login.

Check for Access to DBA ViewsDefault - UncheckedIf you have access to the DBA views, such as DBA_TAB_COLUMNS, then checkthis option. At session startup, TOAD will see if DBA views are available to thatparticular user schema. If so, TOAD will query the Oracle Dictionary using theDBA views instead of the ALL views such as ALL_TAB_COLUMNS. DBA viewsdo not have security checks, so they're faster than ALL views.

Page 366: Toad Users Guide

366

Check for Access to DBMS_Transaction to Prevent Unnecessary CommitReminders checkboxDefault – UncheckedIf you have access to the DBMS_Transaction package, check this option. TOADwill check for it, and use it instead of prompting for commit reminders.

Page 367: Toad Users Guide

Chapter 10 Other TOAD Options and Features 367

Files OptionsSave Files in Unix FormatDefault – UncheckedIf checked, files are saved without CR/LF pairs. Tabs are converted to spaces.

Export File Extensions

ProceduresEnter the desired file extension for exporting procedures. The default is PRC.

FunctionsEnter the desired file extension for exporting functions. The default is FNC.

Package SpecificationsEnter the desired file extension for exporting package specifications. The default isPKS.

Package BodiesEnter the desired file extension for exporting package bodies. The default is PKB.

TriggersEnter the desired file extension for exporting triggers. The default is TRG.

ViewsEnter the desired file extension for exporting views. The default is VW.

File Load/Save Dialog FiltersNearly all of the File Open and File Save dialog windows displayed through TOADare for the purpose of manipulating SQL files. The grid dialog allows you tocustomize the file extensions that display in the system dialog windows. To addanother filter, begin typing in a blank row. To delete a filter, highlight the text andpress the <DELETE> key.

Page 368: Toad Users Guide

368

These are the default filters:FILE TYPE FILTERSQL *.sqlText Files *.txtQuery Files *.qryAll Files *.*

File Association dialog

This will create a windows file association for the specified file extensions. If youwere to double-click in the file explorer on a *.SQL file, for example, then TOADwould startup automatically.

Page 369: Toad Users Guide

Chapter 10 Other TOAD Options and Features 369

Source Control OptionsTOAD Source Control Options

The TOAD Source Control Options are for TOAD VCS (Version Control System).TOAD Source Control is enabled through the TOADVCS.SQL script.

Prompt to check in all objects when closing connections

Default – Unchecked

If you've checked out objects through TOAD Source Control (TOAD VCS), beforeclosing connections you'll be prompted to check the objects back in with a YES orNO dialog.

Use TOAD Checkin/Checkout features

Default – Unchecked

If checked, the TOAD VCS checkin/checkout features will be enabled.

Automatically checkout objects before compiling

Default – Unchecked

If checked, TOAD will automatically checkout objects before performing acompile. It uses tables to check out the object.

External Source Control Options radio buttons None, SourceSafe v5.0 or later

Default – None

This option lets you select the desired source control interface.

Default Database dropdown list

Default – Blank

Select the source control database from the list.

Page 370: Toad Users Guide

370

VSS Login User Name

Default – Blank

Enter the User Login name.

Page 371: Toad Users Guide

Chapter 10 Other TOAD Options and Features 371

Printing OptionsUse syntax highlighting when printing source code

Default - Checked

If checked, TOAD will print source code from the SQL Edit window or ProcedureEdit window using the same colors as are displayed in the windows. If unchecked,TOAD will print the source code in standard black and white.

Reports Font textbox

Default – Courier Regular 9

This displays a sample of the font used by the TOAD Reports function. To changethe font, click the drilldown "..." button.

Page 372: Toad Users Guide

372

Tuning Server Statistics

You get to the TOAD Server Statistics window via the Tuning > Server Stats menuitem.

This is a DBA (Database Administrator) function. Use this dialog to viewinformation about how the Oracle instance is performing.

On the Analysis tab, the upper and lower warning and error thresholds and messagescan be configured in the TOADSTATS.INI file in the TOAD\TEMPS folder.

Page 373: Toad Users Guide

Chapter 10 Other TOAD Options and Features 373

This window helps database administrators tune their databases.

Since this dialog is intended for DBAs, access to certain SYS views is required toquery and display the information. If you want to give a TOAD user access to theServer Stats window without granting them the DBA role, see the TOAD Help file,TOAD.HLP, topic Windows: TOAD Server Statistics for a complete list of SYSviews to grant select access to the destination user.

The dialog is composed of the following tabs: Analysis, Waits, Latches, Sessions,Instance Summary, Locks, and Monitor.

Analysis

To set the warning light threshold values, see the topic “How to create yourTOAD\temps\toadstats.ini file” in the TOAD help dialog TOAD.HLP.

Analysis shows high level database information such as gets, misses, and cache hits.This information comes from the SYS.V$SYSSTAT view, and other views.

Waits

Shows detailed information about database waits, from theSYS.V$SYSTEM_EVENT view

Latches

Shows detailed information about database latches, from the SYS.V$LATCH view

Sessions

Shows a master/detail presentation of the current sessions, from theSYS.V$SESSION view, and other views. The top grid lists the sessions, whereas thebottom grid lists the detailed information about the selected session, from theSYS.V$SESSTAT view.

Instance Summary

Shows overall instance statistics from the SYS.V$SYSSTAT view

Page 374: Toad Users Guide

374

Locks

Shows the current table and row locks in the database, fromSYS.V$LOCKED_OBJECT view, and other views

Monitor

Shows five graphs of database performance information: Sessions, Cache HitPercent, SGA Memory Usage (Oracle 8 or higher), Shared Pool (Oracle 8 or higher),and Indexed Queries Percent

NOTE: The TOADSTATS.INI file contains default values that are decimal valuesthat use the American "." (period) as a decimal character. If your locale settingsrequire a different decimal character, you should either edit TOADSTATS.INI ordelete the file entirely.

Page 375: Toad Users Guide

Chapter 10 Other TOAD Options and Features 375

SGA Trace Optimization

You access this window via the Tuning > SGA Trace Optimization menu item.This is a DBA (Database Administrator) function.

Oracle's SGA (System Global Area Oracle Shared Memory) is a pool of the mostrecently used SQL statements. Not all SQL statements can be retained in the SGAforever, because it is a limited size. The least frequently used statements arediscarded in favor of new ones.

The dropdowns let you select the sort order of the results, the type of statement andthe user or all users.

You can further filter by showing only statements with a specific number ofexecutions (more than one), and/or only those statements containing a specifickeyword.

Once your filters are set, click the Refresh the List of Statements toolbar button.

If you want to work with a particular SQL statement in more detail, click the Loadselected statement into the SQL Editor toolbar button.

Page 376: Toad Users Guide

376

The SQL Text and the Tabs in the bottom window (SQL, Execution Stats, andExplain Plan) are the details for the selected SQL.

Execution Stats

Shows information about the selected SQL statement.

SQL

Shows the entire SQL for the selected SQL statement.

If you get the "SQL Body Unavailable" message when clicking on the SQL tab, thenthe SQL is not present in Oracle's SGA, which is a pool of the most recently usedSQL statements. Not all SQL statements can be retained in the SGA forever, becauseit is a limited size. The least frequently used statements are discarded in favor of newones.

Explain Plan

Shows the Explain Plan for the selected SQL statement in the "SQL Shared Pool"tab. The total cost of the statement is displayed in the Total cost for statement label.If the cost information is not available because of rule based optimization, then thislabel will be blank.

You can only view the execution plan for a statement if you have rights to access thereferenced objects in the statement.

Page 377: Toad Users Guide

Chapter 10 Other TOAD Options and Features 377

Estimate Table Size

You get to this dialog via the Tuning > Estimate Table Size menu item.

Use this dialog to estimate how much disk space a table might require given anestimated number of rows.

Page 378: Toad Users Guide

378

To Estimate the Table Size1 Select a Table Owner from the Owners dropdown list.

2 Select a Table from the Tables dropdown list.

3 The Block Size is retrieved from the database and populated in the Block Sizetextbox.

4 Enter the number of estimated rows of table data in the Estimated number ofrows textbox.

5 Select an estimation option:

(a) Calculate based on average row size of existing data. Caution: this maytake a while because the virtual storage size for all data must be summed andaveraged. The more data you have in the table, the longer this will take. If thereare no rows of data in the table, an error will result. Select a different estimationoption. Once the row size calculation has completed, the average row size valuewill be populated into the Row Size textbox.

(b). Calculate row/data size from table structure (DDL). The row size isdetermined by adding together the DATA_LENGTH from the Oracle Dictionaryfor every column in the table. Once the row size calculation has completed, therow size value will be populated into the Row Size textbox.

(c). Use row/data size from analyzed table info. The table must be analyzedbefore selecting this option. If the table was previously analyzed, the row sizewill be populated in the Row Size textbox and the number of rows will bepopulated into the Estimated Number of Rows textbox. If the table was NOTpreviously analyzed, the Row Size textbox will be empty.

6 Click the CALC button. The estimated table size will now be calculated anddisplayed in the Estimated Table Size textbox. This value is in bytes.

NOTE: These estimation values are based on how much disk space the table dataoccupies. These values differ from the EXTENTS values displayed on the SchemaBrowser window, Tables tab, Stats/Size tab, because EXTENTS are containers thatstore data. Extents are created with a certain container size, e.g., 1MB. Each extentcould be empty, half full, three quarters full, or full. In all of these cases theEXTENT size remains the same, 1MB, but the amount of disk space occupied bydata changes.

Page 379: Toad Users Guide

Chapter 10 Other TOAD Options and Features 379

Estimate Index Size

You get to this dialog via the Tuning > Estimate Index Size menu item.

Use this dialog to estimate how much disk space an index might require given anestimated number of rows. This dialog is almost identical to the Estimate Table Sizedialog.

To Estimate Index Size1 Select an Owner, Table, and Index.

2 Enter the Estimated number of rows of data in the table.

3 Select an estimation option:

(a). Calculate based on average row size of existing data.

(b). Calculate row/data size from table structure (DDL).

4 Click the CALC button to calculate and display the Estimated Index Size.

Page 380: Toad Users Guide

380

Profiler Analysis (Oracle 8i only)

Oracle8i provides a Probe Profiler API to profile existing PL/SQL applications andto identify performance bottlenecks. The collected profiler (performance) data can beused for performance improvement efforts or for determining code coverage forPL/SQL applications. Code coverage data can be used by application developers tofocus their incremental testing efforts.

The Profiler API is implemented as a PL/SQL package, DBMS_PROFILER, thatprovides services for collecting and persistently storing PL/SQL profiler data.

The Profiler reviews previously collected statistics. It’s a two step process. Collectthe statistics. Analyze the statistics. To collect the statistics you have to turn theProfiler on by depressing the Toggle PL/SQL Profiling button (the stopwatch icon)or selecting the Database > PL/SQL Profiling menu item.

Page 381: Toad Users Guide

Chapter 10 Other TOAD Options and Features 381

Using DBMS_PROFILERImproving application performance is an iterative process. Each iteration involvesthe following:

1 Exercising the application with one or more benchmark tests, with profiler datacollection enabled.

2 Analyzing the profiler data, and identifying performance problems.

3 Fixing the problems.

To support this process, the PL/SQL profiler supports the notion of a run. A runinvolves running the application through benchmark tests with profiler datacollection enabled. You can control the beginning and the end of the run by clickingthe Toggle PL/SQL Profiling button in the main TOAD toolbar.

A typical session involves:1 Starting profiler data collection in session.

2 Executing PL/SQL code for which profiler/code coverage data is required.

3 Stopping profiler data collection.

Some PL/SQL operations, such as the first execution of a PL/SQL unit, mightinvolve I/O to catalog tables to load the byte code for the PL/SQL unit beingexecuted. It could take some time executing package initialization code the first timea package procedure or function is called. To avoid timing this overhead, you shouldwarm up the database before collecting profile data. Warming up involves runningthe application once without gathering profiler data.

Collected Data

With the Probe Profiler API, you can generate profiling information for all namedlibrary units that are executed in a session. The profiler gathers information at thePL/SQL virtual machine level that includes the total number of times each line hasbeen executed, the total amount of time spent executing that line, and the minimumand maximum times spent on a particular execution of that line.

The profiling information is stored in database tables. This enables the ad-hocquerying on the data. It lets you build customizable reports (summary reports, hottestlines, code coverage data, etc.) and analysis capabilities.

Page 382: Toad Users Guide

382

With Oracle8i, a sample textual report writer is provided with the PL/SQL demoscripts.

To set up the ProfilerNOTE: The minimum Oracle database version required for the PL/SQL Profiler isOracle 8i.

1 Make sure you have the SYS.DBMS_PROFILE package or load theORA8I\RDBMS\ADMIN\PROFLOAD.SQL script if you do not already have it.Make sure that GRANT EXECUTE on the DBMS_PROFILE package has beengranted to PUBLIC or the users that will use the profiling feature.DBMS_PROFILER must be installed as SYS.

2 Run the TOADProfiler.SQL script. You can find a copy of the script in theTOAD\TEMPS folder. This script will create the tables, package, synonyms,and grants required to do profiling. It is recommended that you install theseobjects in the TOAD schema, but you can select whatever schema is appropriateto your environment.

To use the Profiler

1 Select the Database > PL/SQL Profiling menu option to turn on the profiler, orclick the Toggle PL/SQL Profiling button in the main TOAD toolbar.

2 Execute a procedure from the Schema Browser OR the Stored Procedure Editorusing the Execute button. You will be prompted to enter a description of theprocedure being executed. This will show up in the Profile Analysis windowwhen you are analyzing the results. Run the procedure several times to get somedata into the profiling tables. You can turn off profiling if you want to. Becareful not to leave the profiler toggled on when you switch to other TOADwindows. Otherwise, profiler data will be collected from the queries TOADperforms to populate those windows.

This stopwatch button is in the depressed position indicating that theProfiler is ON.

Page 383: Toad Users Guide

Chapter 10 Other TOAD Options and Features 383

3 Select the Database > Profiler Analysis menu item. The Profiler Analysiswindow will display. There are three levels to the data. The top level containsthe individual Runs of each procedure executed while profiling was enabled.Double-click on one item for the execution stats for that individual run. At thislevel, you can double-click to see the line-by-line performance times forindividual procedures called during profiling.

The top half of the window is a pie chart (or bar chart, depending on your selection)showing the percent of time required to run each component of the procedure.

The labels on the chart show actual execution time in milliseconds, whereas thevalues in the legend are the percent of execution time. There are labels for fastest,slowest, and average unit or line of code.

The bottom half of the window lists the runs, including Run Number, Procedure,Timestamp, Total Time to execute, and Comment. To sort in ascending ordescending order, click the column header of the column you want to sort. A blacktriangle pointing up (in the column header) indicates order – up is ascending, down isdescending.

Chart labels show execution time.

The legend shows thepercent of execution time.

Page 384: Toad Users Guide

384

Drilling down on a run will list the details of the run including Unit Type, Owner,Unit Name, and Total Time to execute.

When drilling down you see the lines of code executed and profiled. The columnheaders change to Line Number, Passes (how many times each line of code wasexecuted), Total Time to execute the line, Min Time, Max Time, and the line ofCode itself.

Above the Profiler toolbar is a horizontal splitter that divides the top half of thewindow and the bottom half. Drag it up or down to show more or less detail.

Page 385: Toad Users Guide

Chapter 10 Other TOAD Options and Features 385

Profiler Toolbar Buttons

Drill Up/Drill Down

Select a wedge of the pie and double-click to drill down, showing the amount of timerequired to execute each statement in the procedure. To drill back up, click the LessDetail Left Arrow button in the Profiler Analysis toolbar. The More Detail RightArrow button can also be used to drill down. You can also double-click on aprocedure name in the list to drill down.

Select a procedure in the list, and click the Procedure Edit Window toolbar buttonto load the selected procedure into a Procedure Edit Window.

If you switch to other windows to execute procedures for profile analysis, and switchback to the Profiler Analysis window, click the Refresh Profiler button to requerythe profiler tables.

Refresh Profiler

Procedure Editor

More Detail/Less Detail

Here, the left arrow would drill back up and the right arrow would drill down.

Page 386: Toad Users Guide

386

If you want to filter OUT certain profiler analysis data, such as all calls ofSYS.DBMS_OUTPUT, click the Profiler Filters button on the Profiler Analysistoolbar, to display the Profiler Filters window. Select the schemas that you want tofilter out.

If you want to remove a set of profiler analysis data for a particular run, select therun and click the Delete Run button on the Profiler Analysis toolbar. The data willbe deleted from the profiler tables. The Delete Run button is only enabled when arun is selected. Drill back up to show less detail in order to select a run.

Profiler Filters

Delete Run

Page 387: Toad Users Guide

Chapter 10 Other TOAD Options and Features 387

You can chPie Chartbutton will

When youselect the c

When viewor maximiz

If you clickvisual dispor value. T

Ba chart

Pie Chart

Rot

Gra

r

ange the graph from a pie chart to a bar chart or vice versa by clicking the or Bar Chart buttons on the Profiler Analysis toolbar. The selected be depressed.

click each pie chart wedge or bar chart bar, the list at the bottom willorresponding item.

ing the pie chart, if the labels overlap, try using the Rotate Graph button,e the Profiler Analysis window to give it more client space.

the Graph Properties button, a dialog displays that lets you change thelay of the graph and/or group together values below a certain percentagehis is useful when you have several small pie wedges or bars.

ate Graph

ph Properties

Page 388: Toad Users Guide

388

� 3D

3D Enabled is checked by default, causing the chart to be three-dimensional. Ifyou uncheck the Enabled box, your chart will be two-dimensional.

If 3D Enabled is checked, you can set the percentage of dimension and theelevation.

� Pie Chart Grouping

Radio buttons lets you choose None, Below percentage, or Below value.

� Gradient

If the Gradient Enabled box is checked, you can choose a multi-colorbackground with a start color and an end color. The two color gradient gives thebackground a gradual backlight effect. If you prefer one solid color, you canchoose the same color for your start color and your end color.

Radio buttons let you choose a direction for your gradient such as left to right,from the corner, etc.

Once you’ve completed your graph properties selections, click OK and your graphwill display with your new colors.

If you can see the pie chart labels but you can’t see the pie chart, resizethe window horizontally to allow more drawing space.

Hiding Profiler Data

If you right-click over the list, you can temporarily hide some data so that a betteranalysis of the remaining data can be performed.

Page 389: Toad Users Guide

Chapter 10 Other TOAD Options and Features 389

For example, if a particular statement takes 95% of the overall execution time, hideit, and the remaining statements, which were under 1% each will blow up to a largerrelative percentage on the graph.

Page 390: Toad Users Guide

390

In this example, the Profiler shows that PROFILER_TEST_PROC took 1940.2629 milliseconds to run(or 1.94 seconds). The legend shows the total number of runs the user profiled, which in this case was 2,the fastest run, the slowest run, and the average run. The legend also shows the percentage of total time(of all runs profiled) for each procedure.

Page 391: Toad Users Guide

Chapter 10 Other TOAD Options and Features 391

TOAD HELP has other examples and more information about the Profiler.

Drilling down from the previous example, the Profiler shows line 15 looped 15,164 times in 3.1966milliseconds. It also reveals total times and code for the other lines. You can click on the different partsof the pie to see the corresponding code. The legend shows the total lines of code for the selectedprocedure, and the fastest, slowest and average lines. The legend also shows the percentage of the totalexecution time for each line.

Page 392: Toad Users Guide

392

Object Browser (Oracle 8 or 8i only)

This window lets you create, browse, edit, and manipulate Oracle 8 objects.

NOTE: that the Object Browser ONLY works on Oracle 8 (8.0.5.0.0) or higherdatabases.

You get to this window via the Database > Object Browser menu item.

Objects PanelThe Object panel (left side of the window) list object types in a hierarchy display. Adropdown list lets you select a schema. You can browse or edit objects in otherschemas, if you have appropriate Oracle Database privileges.

You can drill down or up by either double-clicking the object, or single-clicking overthe expand (plus) or collapse (minus) symbols. You can also drill down by pressingthe "+" (PLUS) key on the numeric keypad, "-" (MINUS) to drill up, and "*"(ASTERISK) to expand all.

Once you select an item, a second click brings the name of the object into edit modeso you can rename the object. Type in the new name and press <ENTER>.

Icons for the objects in the hierarchy:

Object

Attribute

Method

Object changed but not yet recompiled

Page 393: Toad Users Guide

Chapter 10 Other TOAD Options and Features 393

If an object name cannot be displayed in the given amount of horizontal screenspace, a tooltip popup displays with the complete object name.

A vertical splitter divides the objects panel (left panel) and the details panel (rightpanel). To move the splitter left or right, click and drag it.

The name of the selected object appears in the status panel at the bottom of thewindow, even while you manipulate items on the details panel.

Right-Click in the objects panel to display the following menu.

Compile

Compiles the selected object.

Drop

Drops the selected object.

Rename

Renames the selected object, method, or attribute to a different name.

Remove

Removes the selected attribute from the object.NOTE: You cannot remove methods.

Page 394: Toad Users Guide

394

Go To

Switches to the Body tab and positions the cursor on the selected method. (Go Tobecomes enabled when selecting a method)

Privileges

Allows you to grant EXECUTE privilege to other users or roles.

Expand All

Expands all of the nodes in the tree.

Collapse All

Collapses all of the nodes in the tree.

Rules for Object Creation1 Every object must have at least one attribute.

2 Every object an object refers to (in attribute, function, or parameter data types)MUST first be complete itself. If it's in another schema, EXECUTE privilegemust have been granted.

If your object comes up as "Status: Incomplete" it will often notdisplay any attributes or methods under it in the tree. This is becausethere is an error in the object that the user must discover and resolve.Make sure you followed the Rules for Object Creation, and check forsyntax errors.

Page 395: Toad Users Guide

Chapter 10 Other TOAD Options and Features 395

Details PanelThis details panel displays details of the object that you select from the objects panel.

When the root node, Object Types, is selected, a list of Objects displays on thedetails panel. This list includes the object name, number of attributes, number ofmethods, and the following true/false statuses: Predefined and Complete. The list issorted alphabetically.

When an object is selected, the details panel displays a three-tab interface listing:Properties, Specification, and Body.

When an attribute is selected, the Properties tab displays detailed information aboutthe attribute, including data type, schema, object, length, precision, and scale.

When a method is selected, the Properties tab displays a list of parameters to themethod, the method type, and restrictions of the method.

Page 396: Toad Users Guide

396

Properties Tab

Objects

When an object is selected in the hierarchy, the Properties tab displays:

1 A list of tables created based on the object.

2 A list of columns whose data type is either a REF or nested reference to theobject.

3 A list of dependencies on the object, including other Oracle objects such aspackages.

Options on the View > Options > Object Browser node, lets you have TOADautomatically query and load these three lists. With the option on, it takes a fewseconds more to query and display this information. If your "Autoload" options areoff, then you can right-click over the three lists and select Load from the menu toload each list individually.

Attributes

When an attribute is selected in the hierarchy, the Properties tab lets you select oradjust the settings for the attribute. You can select from the basic data types for theattribute, e.g., INTEGER, VARCHAR2, DATE, etc., or select REF or Nested Objectto refer to other objects, in which case Schema and Object dropdown lists becomeenabled.

Methods

When a method is selected in the hierarchy, the Properties tab displays a list ofparameters to the method, including parameter name, data type, mode (IN, OUT,etc.), and Object.

The Properties tab contains a dropdown list to select the method type (Procedure,Function, Map Function, or Order Function), a label indicating if the method isoverloaded (True or False), a dropdown for method return data type (if Function),dropdown lists for Schema and Object if the return type is a REF to an object or aNested Object, and checkboxes for method restrictions WNDS, RNDS, WNPS, andRNPS.

Page 397: Toad Users Guide

Chapter 10 Other TOAD Options and Features 397

These method restrictions tells the PL/SQL compiler what sort of access the methodneeds to the database. The compiler can then deny the method read/write access todatabase tables, packaged variables, or both.

WNDS means "writes no database state"WNPS means "writes no package state"RNDS means "reads no database state"RNPS means "reads no package state"

You can Add, Edit, or Delete method parameters by clicking the appropriatebuttons. In the case of Add or Edit, you will be prompted for parameter name, mode(IN, OUT, or IN OUT), data type, and in the case of REF or Nested Object, Schemaand Object.

Map Functions cannot have any method parameters associated with it. If you changefrom Procedure, Function, etc. to Map Function, you will be prompted whether ornot to automatically delete all method parameters.

Order Functions must have one IN parameter of the same type as the object. If youselect Order Function, you will be prompted whether or not to automatically removeall method parameters and add one parameter of the appropriate type.

Specification TabThe Specification Tab displays the source code for the object's attributes andmethods. As with any memo editor in TOAD, you can select the text via mouseselect or <CTRL>A and copy it elsewhere via <CTRL>C.

Body TabThe Body Tab shows the code for the object's methods. If there are no methods, thebody tab is empty.

Page 398: Toad Users Guide

398

Details Panel Toolbar

Compiles the object, saving it to the database, and resets the "new" bitmap in thehierarchy. The dropdown lets you select to compile a single object or all the objects.

Creates a new object, adding it to the Object Types hierarchy list. The name of thenew object is adjustable in the View > Options > Object Browser dialog. Thedefault name in the options menu is NEWOBJECTX (X being an integer that starts at1 and increments by 1 with each new object name). An attribute is also automaticallycreated, because object types must have at least one attribute.

Creates a new attribute, adding it to the selected object. The name of the newattribute is adjustable in the View > Options > Object Browser dialog.

Creates a new method, adding it to the selected object. The name of the new methodis adjustable in the View > Options > Object Browser dialog. You can select eithera New Procedure, New Function, New Map Function, or New Order Function.

Builds the Specification and Body information from the database. NOTE: this willdelete any comments you had previously entered in the method code.

Compile Object

New Object

New Attribute

New Method

Build/Refresh Object Source

Page 399: Toad Users Guide

Chapter 10 Other TOAD Options and Features 399

Drops the selected object. A confirmation prompt precedes the drop.

Grants EXECUTE privilege on the selected object to a list of users and/or roles.

Reloads the object hierarchy tree.

Creates a script for either the selected object or all objects (which you can choosefrom the dropdown).

Loads the selected object into a SQL window for further editing.

Changes session to a different schema and/or database.

Drop Object

Object Privileges

Refresh Tree

Save Object to File

Load Object into SQL Edit window

Change Active Session

Page 400: Toad Users Guide

400

To Use the Object Browser to create objects and types1 Click the New Object button.

2 A new object is created and a new node is added to the hierarchy in the objectspanel. The node is named by default NEWOBJECT1. The default name can bechanged in the View > Options > Object Browser menu.

An attribute is also created and displays in the objects panel in the hierarchytree. (Remember, objects must have at least one attribute). The default name isNEWATTRIB1. The default name can be changed in the View > Options >Object Browser menu.

3 To rename your NEWOBJECT and NEWATTRIB (and NEWMETHOD) toyour desired names, Right-Click on the name you want to change in the objectspanel and select Rename from the Right-Click Menu. Type in the new nameand either press <ENTER> or click outside of the highlighted area.

Page 401: Toad Users Guide

Chapter 10 Other TOAD Options and Features 401

4 The Properties tab allows you to fill in details for the Attributes such as Type,Schema, etc. Notice Type has a dropdown list from which you can choose a typesuch as integer, number, or raw.

5 You can add additional Attributes by clicking the New Attributes button.Rename and fill in the details panel as appropriate.

6 You can add methods by clicking the New Method button. The New Methoddetails panel also includes a dropdown for types. Again, you would rename theNEWMETHOD and fill in the details panel as appropriate for your method.

7 When you have finished adding your attributes methods and their details, clickthe Compile Object button and your object is created.

8 Now the specification tab for the Object will display the syntax for the creationof the object.

The Type dropdown list on the AttributesProperties tab

Page 402: Toad Users Guide

402

Object Browser Options

Go to the View > Options > Object Browser to set options for the Object Browserwindow.

Page 403: Toad Users Guide

Troubleshooting

Frequently Asked Questions

What is the current version of TOAD?

See http://www.quest.com for the latest version information.

Can TOAD connect using 16 bit Oracle SQL*Net?

TOAD is a 32 bit application and therefore requires 32 bit SQL*Net.

Is TOAD compatible with WinSock v2?

TOAD is neither compatible nor incompatible with WinSock. Any compatibilityissues are between SQL*Net and WinSock.

If TOAD Hangs During Splash Screen...

There could be a problem with the sound card or sound devices. Edit TOAD.INI, set“PLAY_WAVE=0”, and try to run TOAD again. You could also renameTOADLOAD.WAV to something else, e.g., TOADLOAD.WAV.OLD, so thatTOAD will not find it or attempt to play it.

Page 404: Toad Users Guide

404

SQL*Net/Net8 Installation Problems

For SQL*Net/Net8 installation problems, follow these steps1 Determine your Oracle_Home value.

Check the Registry under HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

2 Check to see if you have access to ORACLE_HOME\BIN.The most common cause of problems involves the PATH environment variable.ORACLE_HOME\BIN must be in your PATH environment variable.Confirm you have access to the drive and make sure the Oracle Home folderexists.Your PATH should look similar to this:PATH=C:\PROGRA~1\MSOFFICE\OFFICE;C:\WINDOWS;C:\ORAWIN95\BIN;

3 Confirm that the Oracle interface DLL is in the BIN folder.TOAD must have an Oracle interface DLL to connect. It would be ORAxy.DLL,where xy is the database version you are connecting to. So, for 7.1 it isORA71.DLL. For Net8/Oracle8i, the DLL is called ORACLIENT8.DLL.Remember, if this DLL file is not in the bin folder then TOAD cannot connect.

4 Look for TNS Admin value.The TNS Admin value would be a folder name in the Windows registry. This isan optional folder. If it is not present the default isORACLE_HOME\NETWORK\ADMIN

Open up the TNSNAMES.ORA file. It should be in the Admin folder. Makesure the database alias name you are using is in the TNSNAMES.ORA file.

You can click the SQL*Net Help button on the Login window to display theSQL*Net Configuration Help window. It lists Oracle Home(s), whether or notTOAD can find the interface DLL, whether or not your ORACLE_HOME\BINfolder is in your PATH, etc. You can click the Clipboard button to copy theinformation for pasting into an email for technical support.

Page 405: Toad Users Guide

Chapter 11 Troubleshooting 405

You can get help from the Quest Software Web site athttp://www.quest.com/support/index.html

To access TOAD Help while in TOAD, simply press the F1 key. This activates thestandard Windows help dialog with the TOAD.HLP file. TOAD Help includescontents, a searchable index, and details on TOAD’s features. It also contains detailsfor troubleshooting problems.

Page 406: Toad Users Guide
Page 407: Toad Users Guide

Upgrades

Upgrades can be obtained from TOAD’s Download Upgrade page.

To upgrade to the latest version

Go to the Quest Software homepage at http://www.quest.com

1 Click Products.

2 Click Products List.

3 Click TOAD.

4 Click Download Upgrade.

5 The Download Upgrade page displays.

6 Paste or type in your registration key number in the license key string box.

7 Click the Download button.

8 The setup.exe file will download. Run it to upgrade your installation of TOAD.

For more information about licenses, upgrades, and installation files, refer to theTOAD Getting Started Guide.

Page 408: Toad Users Guide
Page 409: Toad Users Guide

TOAD add-on modules

This chapter discusses the optional modules you can purchase that work with andenhance TOAD.

The following optional modules are available for TOAD.� TOAD PL/SQL Debugger™ (refer to the PL/SQL Debugger chapter of this

manual, page 183)� Quest Software SQLab Tuner/Xpert™� Quest Software SQL Impact™� RevealNet PL/Formatter™� RevealNet Knowledge Base™

Page 410: Toad Users Guide

410

Quest Software SQLab Tuner/Xpert

This is a single add-on product available from Quest that is split into two modules,SQLab Tuner and SQLab Expert.

Product Key Capabilities

SQLab Tuner SQLab Tuner is a robust, Windows-based SQL analyzer that can locate and tune"offensive" SQL statements buried within homegrown or commercial applications.SQLab Tuner identifies performance issues and enables Oracle database tuning toresolve bottlenecks.

SQLab Xpert SQLab Xpert takes application tuning to the next level by becoming an instant“expert” on your Oracle database. SQLab Xpert provides context-sensitive tuningadvice for SQL statements based on the Oracle execution plan and the structure ofyour database.

The Tuner identifies, records, and tunes offensive SQL statements. It analyzes aselected SQL statement and makes recommendations that will resolve bottlenecksand improve performance. The Tuner displays different SQL tuning scenarios so thatyou can choose the best strategy. It displays tables and indexes associated with theselected SQL statements. It also lets you see the logic behind its recommendation.

With Tuner, you select a SQL statement, click the Tuner toolbar, and the statement ispassed to the SQLab Tuner for analysis. The Tuner places the resulting statement inthe Windows clipboard, so that you can paste it back into TOAD.

Xpert checks for common database problems, finds SQL problems, and providestuning advice to improve performance. You can have Xpert actually rewrite yourSQL statement based upon the advice you choose. And you can test the new scenarioin a tuning session.

For more information on SQLab Tuner/Xpert, go to the Quest Software site atwww.quest.com. To purchase a copy, contact Quest Sales at 1-800-306-9329 or sendemail to [email protected].

Page 411: Toad Users Guide

Chapter 13 TOAD add-on modules 411

Quest Software SQL Impact

SQL Impact SQL Impact provides impact analysis, documentation and auditing to manage thedependencies between database objects and application’s source code. SQL Impactprecisely determines the components that will be affected by structural changes toa database, drilling down to the lines of source code affected. SQL Impact candocument the access pattern of an application, and provides automated qualityassurance reports on the SQL embedded in the source code. SQL Impact’s Year2000 option supports Year 2000 projects by identifying all date instances andhighlighting problematic date usage in both the database and your source code.

SQL Impact lets you see the impact of a proposed schema change. It determineswhich components of an application will be affected by the changes. It providesaccurate and automatic impact analysis for proposed database changes. You can seehow a schema change will affect source code. It shows you all the lines of affectedcode. It also drills down to the individual lines of source code affected.

For more information on SQL Impact, go to the Quest Software site atwww.quest.com. To purchase a copy, contact Quest Sales at 1-800-306-9329 or sendemail to [email protected].

Page 412: Toad Users Guide

412

RevealNet PL/FormatterPL/Formatter is an optional add on product by RevealNet that formats your SQL foryou while you are in TOAD. With PL/Formatter, while you are in TOAD you caneasily format or reformat code with a right-click of the mouse. It also providesrecommendations to improve your code.

It checks for over 1000 common coding mistakes.

You can set formatting options in the View > PL/Formatter Options dialog.

If you had the following query, and you had installed PL/Formatter, then you couldselect the query, click the right mouse button, and select Format SQL from the popupmenu. This is what would happen.

select first_name, last_name from employee

where first_name like ‘S%’ order by last_name

would get formatted into this:

/* Formatted by PL/Formatter v2.0.8.0 on 2000/03/28 16:22 (04:22 PM)

*/

SELECT first_name, last_name

FROM employee

WHERE first_name LIKE 'S%'

ORDER BY last_name

The trial version of the PL/Formatter will not work with TOAD.

If you purchase the commercial version of the PL/Formatter, it will workwith TOAD.

For more information on PL/Formatter, visit http://www.revealnet.com. To purchasea copy, contact Quest Sales at 1-800-306-9329 or send email to [email protected].

Page 413: Toad Users Guide

Chapter 13 TOAD add-on modules 413

RevealNet Knowledge Base

PL/SQL Knowledge Base is an optional add-on product by RevealNet that is anonline reference that helps you understand and use PL/SQL. You can easily searchand browse index topics.

� It has over 1000 reusable code examples and over 200 scripts.

� It has hundreds of drop-in functions and utilities.

� It’s designed to help you understand and use PL/SQL.

� You can customize the Knowledge Base.

� It complements the Oracle manuals.

Once Knowledge Base is installed, access is as easy as the right-click of your mousewhile you are in a SQL Edit window. Then select Knowledge Base for access to anencyclopedia of information in an online reference, examples, and even practicetests. Use the search engine to launch a keyword search. Get suggestions on how toimprove code in your present script.

The interface from TOAD to the RevealNet Knowledge Base product is containedwithin the REVBASE.DLL file, which must be present in your TOAD folder inorder for the interface to work. REVBASE.DLL is installed by the TOADinstallation script.

For more information on Knowledge Base visit http://www.revealnet.com. Topurchase a copy, contact Quest Sales at 1-800-306-9329 or send email [email protected].

Page 414: Toad Users Guide

414

Page 415: Toad Users Guide

Quest Softwareproducts and solutions

Quest Software delivers solutions that enable optimal performance and reliability ofe-business, packaged and custom applications. Our products ensure availabilitythroughout the application lifecycle with solutions for:

� Development & DeploymentSpeed development while maintaining quality applications and accuratelydeploy changes from development to test to production.

� Production SupportEnsure optimal performance and availability of your production systems with acomprehensive approach that includes enterprise monitoring and diagnostics,database management and high availability solutions.

� Information AvailabilityExtend the reach of valuable enterprise information and instantly deliver it to theusers who need it anytime, anywhere.

Best of breed products that are easy to install and use, provide a quick return oninvestment, and address the complete application lifecycle—from development toproduction and through to information delivery—make Quest Software the numberone solution provider for application and information availability solutions.

The following pages give you a brief overview of our product families. For moredetailed information about their capabilities, please visit www.quest.com/solutions/.

Page 416: Toad Users Guide

416

Development & DeploymentThere's an increasing demand for business applications to be developed and deployedinto production faster than IT can respond. Developers and DBAs alike need aproven set of tools to speed development while maintaining quality applications.And, they need a means to accurately deploy an application and/or changes fromdevelopment to test to production without adversely impacting availability.

SQL DevelopmentDevelopers are expected to develop and enhance applications faster than ever to keepup with the competition, yet developing SQL code with the traditional command lineinterface is time-consuming and tedious. Quest accelerates the development processwith easy-to-use graphical interfaces, robust editors, and integrated tuning andtesting modules that improve the quality of applications before they enter production.

SQLab Xpert™ — proactively tune SQL statements before deploying them toproduction

SQL Impact™ — identify the impact of structural changes to the database beforedeployment

Data Manager™ — quickly build test databases with a logical subset of yourproduction data

DeploymentMaking a structural change to your database can be one of the most challenging tasksof a developer or DBA. A single complex change – such as renaming a column – cantake hours to implement manually. Quest’s deployment tools enable DBAs toautomatically create, version and deploy structural changes to the database in afraction of the time it would take manually while reducing the risk of downtime fromfailed deployments.

Schema Manager™ — safely deploy schema changes to your Oracle databasesfrom development to test to production

Schema Xpress™ — quickly and easily determine, develop and apply schemachanges to your SQL Server databases

Data Manager™ — deploy reference data changes and move data between Oracledatabases

Page 417: Toad Users Guide

417

Application Change ManagementManaging frequent application customizations and upgrades without a changemanagement solution can seriously degrade the performance of your mission criticalapplications. Quest offers a comprehensive solution to specifically address thechallenges of maintaining complex PeopleSoft environments that balances the needto accelerate the upgrade process without losing control of your developmentprojects or risking system stability.

Stat™ — provides version control, change management, migration assistance, andupgrade support functionality for complex PeopleSoft environments

Production SupportIncreased reliance on business applications has lead to zero tolerance for downtimeand slow response time. Quest’s Production Support suite ensures applicationperformance and availability through a combination of monitoring, databasemanagement and high availability solutions.

High AvailabilityQuest Software redefines high availability with our revolutionary log-basedreplication technology. Imposing minimal overhead on the production system, thissolution creates a copy database that is less than seconds behind the source enablingreport offloading, load balancing and failover. The same technology is applied toQuest’s space management solutions to enable “live” reorganizations and objectrestructuring for the 24x7 database.

SharePlex® — enables access to an up-to-the-minute replica of your OracledatabaseLiveReorg™ — reorganize and restructure your Oracle database without incurringdowntime

Page 418: Toad Users Guide

418

Enterprise MonitoringAs more organizations continue to implement complex enterprise systems,maintaining their performance and identifying problems in a timely fashion canbecome a nightmare. Quest reduces the complexity of maintaining a multi-layerenvironment with enterprise-wide monitoring. By intelligently summarizing theinformation IT professionals need to know, Quest offers a practical, easy-to-usesolution for an otherwise challenging environment.

Foglight™ — alerts system managers to actual or potential problems at theoperating system, database and application levels

Database ManagementWith the database as the core of today’s business applications, it is critical thatproblems are detected, diagnosed and resolved as quickly as possible. Quest’sdatabase management products safeguard your Oracle database by quicklyidentifying and resolving common problems, such as bottlenecks, poor performingSQL statements and space-related issues. In addition, proactive schema and datamanagement solutions enable you to better maintain your database without the riskof downtime.

Space Manager™ — quickly reorganize and restructure your Oracle database

SQLab Xpert™ — immediately identify offensive SQL statements and implementexpert tuning advice

Instance Monitor™ — immediately diagnose problem areas throughout yourOracle database by monitoring the actual flow of data and processes

I/Watch™ — monitor and diagnose your database, application and operating systemunattended, 24x7

Schema Manager™ — safely deploy structural changes to your Oracle database

Data Manager™ — migrate logical subsets of production data between databasesfor report offloading and archiving

Page 419: Toad Users Guide

419

Information AvailabilityAs the speed of business increases, so does the amount of business information.Because the ability to make informed decisions is based on access to the mostcurrent information, when it is unavailable or difficult to locate, the entire businesssuffers. Quest’s Information Availability suite gets the information generated byyour homegrown, packaged, and ERP applications—or any electronic document—inthe hands of those who need it, when and where they need it, and in any format.

Enterprise Report ManagementWith enterprise report management, Quest gives you the ability to capture reportsfrom mainframe, legacy, and ERP systems, as well as electronic information fromother applications; store them in a centralized enterprise repository; and make theminstantly available to users online—even over the Internet—right at their desktops.

Vista Plus™ — manages all of the electronic information in your organization,archives it in a central repository, and delivers it to users in any location in a varietyof formats

Vista Plus Java Client™ — enables users worldwide to quickly and securely accessreports and electronic documents over the Internet via a standard Web browser

Vista Plus TransVue™ — offers EDM functionality through intuitive viewing andmanaging of reports and related electronic documents in the same repository forquick and easy access

Vista Plus™ Interfaces for ERP Systems — automatically manages the transfer ofinformation between the Vista Plus and ERP system to reduce administration time,eliminate errors, and speed deployment

•� Vista Plus Interface for Oracle Applications

•� Vista Plus Interface for PeopleSoft

•� Vista Plus Interface for SAP R/3

Output ManagementMore than half of your network traffic is compromised of output delivery. Questmanages this chaos with a Web-based, scalable solution for managing, distributingand tracking output to mid-to-large distributed environments.

QMaster™ — provides a seamless and effective way to automate and ensure outputdelivery and schedule batch processes

Page 420: Toad Users Guide

420

Quest Software Information

Quest Software is headquartered in Irvine, California and has locations in Atlanta,Boston, Chicago, Dallas, New York, San Francisco, Washington D.C., Germany, theUnited Kingdom, Canada, Israel, and Australia.

Feel free to contact Quest Software for product information and pricing in any of thefollowing ways:

Location Telephone

USA and Canada 949-754-8000

FAX: 949-754-8999

UK +44-1628-601000

Germany +49-211-770967-0

Australia +61-3-9811-8000

Email Sales &Marketing

[email protected]

Home page http://www.quest.com

Mail address 8001 Irvine Center DriveIrvine, CA 92618

Page 421: Toad Users Guide

421

Technical SupportIf you have questions about using a Quest Software product, please contact thetechnical support staff. Please include the version number. You can find your versionnumber in the Help > About menu. If your question is about an error message,include the error text as well.

Email [email protected]

Page 422: Toad Users Guide

422

INDEX

A

Advice ................................................................14Aliases ..............................................10, 12, 17, 67

Column.........................................................116Database .....................................9, 13, 360, 404Table.................................33, 67, 323, 330, 333

ALIASES.TXT...................................................67Analyze ......................................................32, 355

All Tables .....................................................268Index.............................................233, 270, 285Table.....................................................233, 268

Anchored ..............................................31, 32, 115Arguments .......... 42, 151, 173, 181, 223, 228, 292ASCII .........................................73, 107, 110, 214Attribute ................... 393, 394, 395, 396, 398, 400

B

BLOB ...............................................104, 121, 123Bookmarks .............................................28, 72, 95Breakpoint ................ 161, 192, 196, 199, 204, 206

Adding..........................................................205Conditional ...................................................207Deleting ........................................................205Disable/Enable .............................................209Editing ..........................................................206Pass Count ....................................................208Setting ..........................................................205

BrowserMaster/Detail ................................................345Object ...........................................................392Schema ............... 29, 32, 64, 118, 178, 184, 231

C

Call Stack ......... 186, 192, 194, 199, 200, 202, 216Capitalization .............................84, 89, 90, 93, 94Change Active Session...............................61, 238

Chart ........................................................ 383, 388Bar Chart ............................................. 383, 387Pie Chart .......................................383, 387, 388Profiler..........................................383, 387, 388

Check In...................................See Source ControlCheck Out................................See Source ControlClipboard51, 63, 95, 109, 126, 132, 256, 259, 276,

317, 327, 361CLOB ...................................................... 104, 121CNVFUNCS.TXT ........................................... 125Coalesce........................................................... 349Code Templates ................................74, 75, 78, 99Colors8, 52, 89, 91, 199. Also See Syntax

HighlightingColumns....102, 106, 110, 111, 113, 123, 257, 270

Column Name Select ....................137, 237, 243Dropdown ................................................ 40, 43

Comment Code.................................................. 75Comments.........................................244, 253, 270Commit ..........47, 48, 362, 366. Also See RollbackCompile ........................................................... 148Configuring the Editor....................................... 69Constraints........................248, 250, 261, 271, 310

Check................................................... 253, 266Create........................................................... 264Disable................................................. 310, 312Enable .......................................................... 310Foreign Key ..................................253, 267, 329Primary Key......................................... 249, 265Unique ................................................. 253, 266

Control Characters............................................. 84Create................114, 165, 234, 246, 251, 351, 382

Constraint ............................................ 264, 265Database Link.............................................. 314DBMS_OUTPUT ........................................ 217Index............................................................ 252Object ............................................ 19, 155, 400

Page 423: Toad Users Guide

423

Procedure .....................................................172Sequence ......................................................297Synonym ..............................................180, 307Table ............................................................123User ..............................................................348

D

Database Links .........................................250, 314Create ...........................................................314List ...............................................................314

Date Format........................ 10, 118, 125, 201, 361DATEFMTS.TXT............................................125Dates ................................................................124DATFUNCS.TXT............................................125DBMS_OUTPUT.............................................127DBMS_PROFILER..................................380, 381DDL Reports ....................................................343Debug............................... 183, 189, 194, 202, 221

Information... 189, 192, 194, 195, 196, 201, 202Symbol Table ...............................195, 196, 229

Debugging 183, 192, 197, 198, 199, 200, 203, 229Functions......................................................221Packages...............................................222, 224Procedures............................................184, 221Triggers ........................................................225

Dependencies ... 184, 201, 242, 244, 250, 289, 292Lower (called objects)..................................189Recompiling .................................................166Upper............................................................184Viewing........................................................184With Debug Information ......................192, 195

Dependent Objects ...................................165, 184Drag and Drop.............. 44, 82, 102, 142, 202, 325

E

Editor................................................31, 37, 60, 69Auto Replace Substitutions ......................67, 73Code Templates..........................74, 75, 78, 100External ................................................130, 133Key Assignments .........................28, 72, 78, 95Offline ............................................................52Parser Scripts..................................................71Procedure ............................... 69, 147, 153, 171Read-Only ...................... 69, 103, 105, 117, 122SQL ..................................................31, 44, 134

Syntax Highlighting................................69, 131Editor Options28, 33, 52, 56, 67, 69, 72, 73, 75,

76, 78, 98, 100, 164, 205Encrypt ...............................................................16End Connection ..................................................17Exceptions ........................125, 200, 265, 266, 267Explain Plan .........................19, 20, 42, 49, 50, 51EXPLAIN.SQL ................................................363Export .......................................104, 111, 118, 367

Data ......................................................233, 257Flat File.................................................110, 337Table Data ....................................................318Table Script ..................................................252

F

Filters........239, 248, 261, 274, 307, 367, 368, 386Data ......................................................239, 273Object Lists...................................................320Object Name.................................................240Schema Browser...................245, 248, 260, 341

Find.......................42, 76, 151, 174, 180, 236, 337Editor....................................42, 56, 75, 76, 101Grid...............................................................112

Fixed.................................................................115

G

Goto......................................................31, 42, 151Grants .......................178, 179, 278, 292, 305, 399GRPFUNCS.TXT ............................................125Gutter................................72, 82, 91, 92, 161, 205Gutter Width.....................................................205

H

Help ........................................8, 40, 125, 373, 405Quest Technical Support ..............................421SQL Templates.....................................125, 126TOAD.............................42, 151, 188, 373, 405

Hotkeys...............................................................28HTML...........................52, 71, 73, 78, 98, 99, 109

Save as..........................................................107HTML.DCI.......................................................100HTMLKEYS.BIN ........................................78, 99HTMLOPTS.TXT ........................................78, 99HTMLSCR.TXT ................................................71HTMLSUB.TXT ................................................73

Page 424: Toad Users Guide

424

I

Import...............................................................123Index.................................270, 283, 286, 341, 379

Analyze ................................................233, 285Create ...................................................252, 352Rebuild .........................................233, 283, 284

INI ..............................................................67, 374As a Language Type.....................71, 74, 78, 99TOAD.INI ..............................................15, 362

INI.DCI ............................................................100INIKEYS.BIN..............................................78, 99INIOPTS.TXT..............................................78, 99INISCR.TXT......................................................71INISUB.TXT......................................................73Initial Caps ...................................................90, 94

J

JAVA.DCI........................................................100JAVAKEYS.BIN .........................................78, 99JAVAOPTS.TXT .........................................78, 99JAVASCR.TXT .................................................71JAVASUB.TXT .................................................73

K

Key...................................................................264Foreign ......... 254, 264, 267, 281, 329, 340, 345Primary......... 244, 255, 258, 264, 265, 298, 328Unique ..........................................................266

Keyboard ............................................................26Keystroke ...............................................28, 29, 74

L

License Key..............................................188, 407Line Numbers...............................................81, 82Load ..................... 74, 85, 133, 154, 375, 396, 399

File..........................78, 122, 142, 164, 360, 367Procedure..............................................195, 385Script ......................................................50, 382

Logoff.....................................See End ConnectionLogon .....................................................9, 12, 350LONG.......................................................104, 121LONG RAW ....................................121, 122, 123LONGSCR.TXT ................................................71Lowercase ....................................................42, 94

M

Make Code......................42, 62, 63, 128, 129, 130Master Detail Browser..................................... 346Memo Editor.........................31, 32, 104, 105, 121Menu...........................26, 198, 241, 352, 358, 359

Right-Click23, 29, 30, 40, 101, 104, 168, 204,210, 235, 327, 329, 334, 337, 338, 393

Message Boxes .................................................. 25Method..............190, 393, 394, 395, 396, 398, 401Mixed Case....................................See Initial CapsMSCFUNCS.TXT........................................... 125

N

NAMEDSQL.DAT.................................... 58, 145NEWFUNC.SQL............................................. 156NEWPACK.SQL............................................. 156NEWPROC.SQL............................................. 156NEWTRIG.SQL .............................................. 156NLS_DATE_FORMAT .................................. 201NMBRFMTS.TXT .......................................... 125NOTOAD.SQL............................................ 19, 49Null ...........................................108, 118, 119, 258Numbers ..................... 90. Also See Line Numbers

Page ....................................................... 81, 106Row.........................................31, 102, 116, 117Run .............................................................. 383

NUMFUNCS.TXT .......................................... 125

O

OPTHINTS.TXT............................................. 125Options

Data Grids.................................................... 117Debugging ................................................... 198Display........................................................... 82Editor ............................................................. 78Editors ......................................................... 131General .................................................. 79, 360Logon............................................................. 12Oracle .......................................................... 362Other85, 87, 89, 93, 95, 97, 104, 169, 367, 369,

412Printing .................................................. 81, 371Procedure Editor .......................................... 163Schema Browser .......................................... 241SQL Editor..................................................... 60

Page 425: Toad Users Guide

425

SQL Modeler................................................339Startup ..........................................................365

P

Package ............................ 149, 182, 185, 287, 367Debugging............................ 190, 222, 224, 228Navigator..............................................157, 166

Parameters......................................See ArgumentsPARAMS.TXT ..................................................59Parse...................................................................42Password ................................................9, 15, 362PATH ...............................................................404Personal Oracle ..................................................17PERSSQLS.DAT .......................................56, 145PL/SQL Profiling ................................ See ProfilerPLSQL.DCI....................................69, 74, 75, 100PLSQLKEYS.BIN .......................................78, 99PLSQLOPTS.TXT.......................................78, 99PLSQLSCR.TXT .........................................71, 72PLSQLSUB.TXT...............................................73Post.....................................................46, 119, 236PREDFXCP.TXT.............................................125Printing.......................................................81, 371

Options ...................................................81, 371Print Grid................................ 31, 105, 337, 345TOAD Reports .......................................77, 371

Privileges32, 178, 179, 260, 278, 279, 289, 292,297, 300Object ...................................................347, 399Role ......................................................347, 348System..................................................347, 348

Probe API.........................................185, 199, 211Procedures

Arguments ......................................42, 181, 182Compile ........................................149, 229, 288Compile Dependencies......... 184, 195, 196, 201Create ...........................................155, 165, 172Dependencies ...............................................184Dependent ....................................................196Errors............................................................159Execute. 149, 160, 176, 183, 189, 222, 223, 385Grants ...........................................................178Privileges......................................................178

Product Authorization ......................................188Profiler .......................................................19, 380Profiler Analysis.................................. See Profiler

Profiling.......................................380. See ProfilerPSEUDO.TXT..................................................125Public 178, 180, 234, 248, 253, 269, 279, 297, 307

Q

Queries12, 59, 101, 102, 117, 124, 134, 139, 144,244, 314, 322, 335, 336, 364Canceling........................................................61

Quest Software .........................405, 407, 415, 420Contacting ....................................................420Other Products..............................................415SQL Impact ..................................................411SQLab Tuner ................................................410SQLab Xpert.................................................410Technical Support.........................................421

R

Radio Buttons .............................................22, 279Rebuild Table ...........................263, 349, 350, 355Redo .....................................................43, 75, 151Referential ................................................250, 281Registration ..............................................188, 407Reports .............................343, 371, 381, 411, 419Reports Font .......................................................77Requirements

Debugger ......................................................185Profiler..........................................................382TOAD Features ..............................................19

Results Grid..............................102, 104, 115, 332REVBASE.DLL...............................................413RevealNet

Knowledge Base...........................101, 409, 413PL/Formatter ..................................31, 409, 412

Roles.........233, 279, 347, 348, 356, 357, 394, 399Rollback ............... 47, 233, 263. Also See CommitRow Numbers.......................................31, 32, 116ROWID ......................................44, 102, 116, 273

S

Save ............................33, 107, 109, 288, 337, 367File............................32, 43, 122, 151, 293, 367Passwords ...............................................15, 362

Schema ...............................19, 261. Also See UserSCHEMA.FLT .................................................245Search7, 55, 76, 101, 112, 165, 184, 341, 342, 413

Page 426: Toad Users Guide

426

Security ....................................................243, 307Passwords .................................11, 15, 348, 362TOAD.....................................................19, 351

Semicolons .......................................................256Sequence ..........................................................296

Create ...................................................234, 297Delete .............................................................96Edit .................................................................96Privileges......................................................297Recreate........................................................298

Set Parameters .. 149, 189, 190, 192, 194, 222, 289Shortcut Keys ...................................145, 221, 222

PL/SQL Debugger........................................194Procedure Editor...........................................151SQL Editor .....................................................40

SHORTSCR.TXT ..............................................71Show All.....................76, 165, 199, 203, 249, 334Single Record View....................................46, 303Sort ........................... 162, 166, 273, 274, 303, 318Source Control....................19, 148, 169, 170, 369

SourceSafe....................................148, 169, 369TOAD...........................................................369

SourceSafe................................148, 169, 170, 182Splitters

Horizontal...............37, 159, 280, 286, 295, 384Vertical .........................................159, 237, 393

SQL Recall .............................................55, 58, 63Named SQLs ..............................42, 55, 57, 145Personal ......................................55, 57, 58, 144Previously Executed .......................................55

SQL Results Grid .......................31, 106, 135, 139SQL*Net ................................12, 14, 17, 403, 404SQL*Plus ...................................................66, 363SQLFILES.TXT...............................................143SQLS.DAT.........................................................56StartUp ...............................37, 147, 231, 359, 365Status Panel Indicator.........................................45Stay on Top ................................................64, 132STRFUNCS.TXT.............................................125Strip Code.....................................42, 63, 128, 129Synonym131, 136, 181, 253, 269, 297, 307, 308,

309Create ...................................................180, 269Filter .............................................................307View .............................................................309

Syntax Highlighting .69, 72, 76, 90, 131, 164, 371

T

Tab Delimited.................................................. 108TAB Key ........................................................... 26Table32, 44, 67, 109, 134, 136, 250, 251, 322,

377Add Column ................................................ 262Analyze........................................................ 268Comments.................................................... 253Create........................................................... 251Drop............................................................. 269Export Data.......................................... 110, 257Filter ............................................................ 260Privileges ............................................... 90, 260Rebuild ................................................ 349, 350Referential ................................................... 281Script ....................................251, 252, 256, 350Select ............................................. 44, 131, 343Truncate....................................................... 263

Tablenames.............43, 69, 90, 131, 152, 249, 364Viewing ........................................... 44, 68, 245

Tabs (in the editor text) ..................................... 87Templates ........................................................ 133

Code Completion................................... 74, 133New Function .............................................. 156New Package ............................................... 156New Procedure .............................133, 156, 166New Trigger................................................. 156SQL Help..................................................... 125

TEXT.DCI....................................................... 100TEXTKEYS.BIN......................................... 78, 99TEXTOPTS.TXT ........................................ 78, 99TEXTSCR.TXT................................................. 71TEXTSUB.TXT ................................................ 73Thread................................................................ 61Time Values..................................................... 124Timeout.................................................... 187, 201TNSNAMES.ORA ...........................9, 10, 12, 404TOAD.......................................7, 8, 321, 403, 409

Modules ....................................................... 409Schema .........................15, 17, 19, 49, 351, 382Security........................................................ 351Upgrading .................................................... 407

TOAD Getting Started Guide .............................. 8TOAD.HLP ..................................................... 405TOAD.INI ........................................... 15, 16, 201

Page 427: Toad Users Guide

427

TOADLOAD ...........................................166, 403TOADPREP.SQL.............................19, 20, 49, 50TOADPROFILER.SQL .....................................19TOADSECURITY.SQL.....................................19TOADSTATS.INI............................................372TOADVCS.SQL ................................................19Toggle .................. 40, 42, 151, 333, 380, 381, 382Toolbars .....................................................33, 273

Common Edit ......................... 37, 125, 126, 150Main ...............................................................35Procedure Edit..............................................148Procedure Edit Status ...................................197Profiler .........................................................385Schema Browser...........................................232SQL Edit ........................................................37SQL Modeler................................................326

Trace ........................ 190, 200, 353, 354, 355, 375Into ............................... 149, 189, 192, 194, 195Out........................................ 149, 189, 192, 194

Triggers .... 225, 240, 245, 254, 272, 293, 295, 367Compile ................................................233, 293Disable .................................................234, 294Drop .............................................................294Enable...........................................................234Filter .............................................................294

Truncate .............................................32, 233, 263

U

Uncomment Code...............................................75Undo.................................................151, 170, 263Update Grid Edits...............................................48Upper Dependency...........................................184

Uppercase ...............................................43, 90, 94User ..........................................9, 20, 90, 166, 243

Create ...................................................347, 348List................................................237, 278, 279Modify..........................................................348

USRFUNCS.TXT ............................................125

V

Variables...................................186, 199, 211, 329Bind ................................................................59Bound .............................................................63Substitution.....................................................59

Version Information .........................................403Views..................32, 131, 250, 299, 325, 343, 367

Compile ........................................................300Filter .............................................................300Privileges ......................................................300

W

Watches149, 189, 193, 199, 201, 210, 211, 213,215, 228

WindowsDockable.......................................................202MDI ................................36, 127, 152, 165, 365Modal .......................................................27, 35Navigation ......................................................21

Windows Clipboard......................... See ClipboardWindows Stay on Top ..................See Stay on TopWord Wrap.........................................................83Word-Wrap Column...........................................83


Top Related