toad (tool for oracle application developers) · pdf filetoad (tool for oracle application...

6
APPENDIX C TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) INTRODUCTION TOAD is a tool from Quest Software (www.quest.com) for creating and testing PL/SQL code. It offers many features for developers and DBAs and is available in a variety of versions. This appendix uses TOAD for Oracle version 11.5. You can download a trial version of TOAD at the Quest Software Web site. NOTE To download the software, you must supply a business e-mail address for Quest Software. This appendix gives you an overview of TOAD and explains how to use it to enter and run both SQL and PL/SQL statements. To explore this tools features, visit the Quest Software Web site, which offers information, data sheets, and white papers. CONNECTING TO A DATABASE First, you must establish a connection to access database objects, such as tables. Follow these steps to create a new connection: 1. Start TOAD. The database login window shown in Figure C-1 opens. Enter the connection information for your database. (Check with your instructor if youre not sure what to enter.)

Upload: dangduong

Post on 10-Mar-2018

252 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

A P P E N D I XCTOAD (TOOL FOR ORACLEAPPLICATION DEVELOPERS)

I N T R O D U C T I O N

TOAD is a tool from Quest Software (www.quest.com) for creating and testing PL/SQL code. It offers

many features for developers and DBAs and is available in a variety of versions. This appendix uses

TOAD for Oracle version 11.5. You can download a trial version of TOAD at the Quest Software

Web site.

N O T ETo download the software, you must supply a business e-mail address for Quest Software.

This appendix gives you an overview of TOAD and explains how to use it to enter and run both

SQL and PL/SQL statements. To explore this tool’s features, visit the Quest Software Web site, which

offers information, data sheets, and white papers.

CONNECTING TO A DATABASE

First, you must establish a connection to access database objects, such as tables. Followthese steps to create a new connection:

1. Start TOAD. The database login window shown in Figure C-1 opens. Enterthe connection information for your database. (Check with your instructor ifyou’re not sure what to enter.)

Page 2: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

N O T EAn Oracle TNS connection is shown in Figure C-1, but you have other connection options, such asdirect or LDAP.

2. Next, click the Connect button to open the main TOAD window(see Figure C-2).

FIGURE C-1 Connecting to Oracle in TOAD

Statementarea

Resultsarea

FIGURE C-2 The main TOAD window

C2

Appendix C

Page 3: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

To view database objects, click the Schema Browser button to open a window in thework area with available objects listed in the left pane. After you select an object, tabs inthe right pane display information about the object. For example, in Figure C-3, a tablehas been selected in the left pane, and the right pane includes tabs for columns, indexes,constraints, and so forth.

EXECUTING STATEMENTS

You can enter SQL statements or PL/SQL blocks in the statement area. In Figure C-4, anSQL statement has been entered in the statement area. Clicking the Execute Statementbutton runs the statement and displays its output in the lower pane.

Schema Browserbutton

Object type tabs

Information for theselected object isdisplayed in tabs

FIGURE C-3 Using the schema browser to view database object information

Execute Statement button

SQL statement and output

FIGURE C-4 Executing an SQL statement

C3

TOAD (Tool for Oracle Application Developers)

Page 4: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

To send the results to an external file, you can right-click the output area and clickSave As. It’s a quick way to export data for others to use in programs such as Microsoft Excel.

Figure C-5 shows creating a PL/SQL procedure in the statement area. When youclick the Execute Script button, the output indicates a successful compilation orcompilation errors.

Before testing the procedure, you need to enable DBMS output so that you can viewtest results. Click the DBMS Output tab in the results area, and then click the buttonshown in Figure C-6.

Execute Scriptbutton

PL/SQL statementand output

FIGURE C-5 Executing a PL/SQL statement

C4

Appendix C

Page 5: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

To run the procedure, right-click it in the left pane and click Action Console. In theAction Console dialog box, click Execute Procedure, and then click OK. The SetParameters window shown in Figure C-7 opens with an anonymous block createdautomatically to test the procedure. This block contains a call to the procedure. To testit, you need to set values for any IN parameters and add DBMS_OUTPUT statements todisplay values. Figure C-7 shows how the supplied block is modified.

The Turn OutputOn button

FIGURE C-6 Enabling DBMS output

FIGURE C-7 Testing a procedure

C5

TOAD (Tool for Oracle Application Developers)

Page 6: TOAD (TOOL FOR ORACLE APPLICATION DEVELOPERS) · PDF fileTOAD (Tool for Oracle Application Developers) To send the results to an external file, you can right-click the output area

Click OK to run the procedure. Processing returns to the statement area, and theresults area displays values for OUT parameters (see Figure C-8).

SUMMARY

This appendix has shown you how to get started with TOAD software, including creating aconnection and executing SQL and PL/SQL statements. TOAD has more advancedfeatures to help with PL/SQL development; for example, you can set breakpoints duringprogram unit debugging to view information, such as variable values, while a program isrunning. To explore these features, review product information on the Quest SoftwareWeb site.

Result of test run

FIGURE C-8 Displaying test output

C6

Appendix C