Oracle TOAD Lab Guide

Embed Size (px)

Citation preview

  • 8/10/2019 Oracle TOAD Lab Guide

    1/85

  • 8/10/2019 Oracle TOAD Lab Guide

    2/85

    COPYRIGHT NOTICE

    All ideas and information contained in this document are the intellectual property ofEducation and Research Department, Infosys Technologies Limited. This document is

    not for general distribution and is meant for use only for the person they arespecifically issued to. This document shall not be loaned to anyone, within or outsideInfosys, including its customers. Copying or unauthorized distribution of thisdocument, in any form or means including electronic, mechanical, photocopying orotherwise is illegal.

    Education and Research DepartmentInfosys Technologies LimitedElectronic CityHosur Road

    Bangalore - 561 229, India.

    Tel: 91 80 852 0261-270Fax: 91 80 852 0362www.infy.commailto:E&[email protected]

    http://www.infy.com/http://www.infy.com/mailto:E&[email protected]:E&[email protected]://www.infy.com/
  • 8/10/2019 Oracle TOAD Lab Guide

    3/85

    Document Revision History

    Version Date Author(s) Reviewer(s) Comments

    1.0 21-May-2007 N.Vijayakalyani,Rituza Khare Ajit Ravindran Nair Initial Draft

    2.0 12-Jul-2007 Nihar Bhatt,Pragati Sheel

    N.Vijayakalyani

  • 8/10/2019 Oracle TOAD Lab Guide

    4/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 4 of 85

    BackgroundThis document contains the assignments to be completed as part of the hands on for thesubject ORACLE (Course code: ).

    Note:All assignments in this document must be completed in thesequence in this document in order to complete the course.

    Assignment 1Objective:To learn how to connect to TOAD

    Background:Although on your machine TOAD is pre configured but please follow these stepsto get a feel of how actually this has been configured.

    Step 1:

    Reach TOAD via :Start->All programs->Quest Software->TOAD for Oracle->Toad for Oracle 9.0

  • 8/10/2019 Oracle TOAD Lab Guide

    5/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 5 of 85

    Step 2:Getting connected to Oracle through TOAD supplying your Userid ,Password andHoststring

  • 8/10/2019 Oracle TOAD Lab Guide

    6/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 6 of 85

    Step 3:

    After getting connected to Oracle through TOAD the following screen would appear.

  • 8/10/2019 Oracle TOAD Lab Guide

    7/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 7 of 85

    Summary:You have learnt how to get connected to Oracle using TOAD

    Note:ENRTOAD must be showing your Oracle ID.(eg: TJan07LC1Comp55)

    Assignment 2Objective:To learn how to create tables, apply constraints and generate ER Diagram usingTOAD

  • 8/10/2019 Oracle TOAD Lab Guide

    8/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 8 of 85

    Create the following tablesEMP

    Column name Data type Description

    EMPNO Number(5) Employee number

    ENAME Varchar2(15) Employee name

    SAL Number(8,2) Basic Salary

    MGR Number(5) Managers Emp. number

    DEPTNO Number(3) Department Number

    PROJNO Number(3) Project Number

    DEPT

    Column name Data type Description

    DEPTNO Number(3) Department number

    DNAME Varchar2(15) Department name

    LOC Varchar2(15) Location of department

    PROJECT

    Column name Data type Description

    PROJNO Number(3) Project number

    PNAME Varchar2(15) Project name

    TEAMSIZE Number(3) Size of the project team

    Step 1:Goto Database >>Create >>TableYou will get the following screen.

  • 8/10/2019 Oracle TOAD Lab Guide

    9/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 9 of 85

    Step 2:After adding all the columns to the EMP table the following screen would appear.It shows all the 6 columns of the EMP table with their sizes as well.

  • 8/10/2019 Oracle TOAD Lab Guide

    10/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 10 of 85

    Step 3:

    To add constraints to the already existing columns click on the Constraints tabof the sameform.Click on Add Constraint tab of the form.The following screen will appear.

  • 8/10/2019 Oracle TOAD Lab Guide

    11/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 11 of 85

    Step 4:

    To add the Primary key constraint select the column on which you want to set the property ofprimary key.The selected table column will appear in the Constraint columns.Note:You should have selected only the required columns for the desired constraint.Constraint name will be generated by the tool.The primary key option would have been set to Yes.

  • 8/10/2019 Oracle TOAD Lab Guide

    12/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 12 of 85

    Step 3:

    To add check constraint to the Sal column click on the Constraints tab in the window andchoose Check constraint.It will open a Constraint textwindow to write the logic of check constraint.The check constraint counter will start reflecting the count 1.

  • 8/10/2019 Oracle TOAD Lab Guide

    13/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 13 of 85

    Step 4:

    To check all the applied constraints on the columns go to the database menu and chooseSchema Browser or the same icon will be available in the tool bar.

  • 8/10/2019 Oracle TOAD Lab Guide

    14/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 14 of 85

    Step 5:The following screen would appear.The left frame shows the created tables list.As EMP is the only table that is created so far, so only it will appear in the list.

  • 8/10/2019 Oracle TOAD Lab Guide

    15/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 15 of 85

    Step 6:

    After the creation of all the three tables the following screen would be seen with the leftframe having in list of all the 3 tables.Notice the Table tab in the left frame is selected.

  • 8/10/2019 Oracle TOAD Lab Guide

    16/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 16 of 85

    Step 7:After the creation of a table the constraints on its columns can be checked by clicking on theConstraints tab on the left frame.Then select on any constraint name, the right frame will reflect its details.

  • 8/10/2019 Oracle TOAD Lab Guide

    17/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 17 of 85

    Step 8:

    To check for the ER diagram of the relational schema, click on the Database >> Report >> ERDiagram.

  • 8/10/2019 Oracle TOAD Lab Guide

    18/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 18 of 85

    Step 9:Click on the new ER Diagram(the first icon which is shown tabbed).

  • 8/10/2019 Oracle TOAD Lab Guide

    19/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 19 of 85

    Step 10:Select your UserID in the schema and EMP/EMPLOYEE table name in the table list.Let all the check boxes be ticked.Click on ok.

  • 8/10/2019 Oracle TOAD Lab Guide

    20/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 20 of 85

    Step 11:The following ER Diagram must appear.

    It shows the relationship of EMPLOYEE table with all the other tables in the database viaforeign keys.

  • 8/10/2019 Oracle TOAD Lab Guide

    21/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 21 of 85

    Step 12:

    Save the ERD of the schema by clicking on the save icon at the top of the frame.It will ask for the name ,save it as bitmap file with the extension .bmp.

  • 8/10/2019 Oracle TOAD Lab Guide

    22/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 22 of 85

    Assignment 3Objective:To learn how to create sequence, view and trigger using TOAD

    Step 1:Go to Database>>Create>>Sequence option.

  • 8/10/2019 Oracle TOAD Lab Guide

    23/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 23 of 85

    The following window will appear.

    Step 2:Supply the name of the sequence, the start value and the increment value.

  • 8/10/2019 Oracle TOAD Lab Guide

    24/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 24 of 85

    Step 3:

    To check for the existing Sequences got to Databse>>Schema Browser or you can click on itsicon in the tool bar.

  • 8/10/2019 Oracle TOAD Lab Guide

    25/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 25 of 85

    Step 4:

    Click on the Sequence tab in the left frame.On the right frame it will reflect all the details of the selected sequence.

  • 8/10/2019 Oracle TOAD Lab Guide

    26/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 26 of 85

    Step 1: Select View option from Database >> Createmenu. You will see the followingwindow.

  • 8/10/2019 Oracle TOAD Lab Guide

    27/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 27 of 85

    Step 2: When it is prompting for View Name, type the view name and type the followingquery in the text window provided.

    SELECT deptno, COUNT (empno) as NoofEmpFROM emp

    GROUP BY deptno

  • 8/10/2019 Oracle TOAD Lab Guide

    28/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 28 of 85

    Step 3: Click on Validate Query, and then you will see Query parsed OK, if the query runswithout any errors.

  • 8/10/2019 Oracle TOAD Lab Guide

    29/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 29 of 85

    Step 4: Then click on OK button.

    Objective: To create a trigger using TOAD.Step 1: Select the Trigger option from Database >> Create menu, as shown in the snap shotbelow.

  • 8/10/2019 Oracle TOAD Lab Guide

    30/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 30 of 85

    Step 2: Provide the Trigger name, select the Schema name and Table name on which thetrigger is to be created.

  • 8/10/2019 Oracle TOAD Lab Guide

    31/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 31 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    32/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 32 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    33/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 33 of 85

    Step 3: Also click on the Fire when, Fire onand For eachoptions as given below

  • 8/10/2019 Oracle TOAD Lab Guide

    34/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 34 of 85

    Step 4: Select the When Clausewindow and provide the condition for the when clause asgiven below.

    NEW.job = SALESMAN

  • 8/10/2019 Oracle TOAD Lab Guide

    35/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 35 of 85

    Step 5: Provide the trigger body as given below.BEGIN

    IF INSERTINGTHEN :NEW.comm := 0;ELSIF :OLD.comm IS NULL

    THEN :NEW.comm := 0;ELSE:NEW.comm := :OLD.comm + 0.12;

    END IF;

    And click on OK button.

  • 8/10/2019 Oracle TOAD Lab Guide

    36/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 36 of 85

    Step 6: Finally you can see the trigger created from Schema browser.

  • 8/10/2019 Oracle TOAD Lab Guide

    37/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 37 of 85

    Assignment 4Objective:To learn how to create a Store Procedure, SP template and how to call a SP froman anonymous block using TOAD.

  • 8/10/2019 Oracle TOAD Lab Guide

    38/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 38 of 85

    Step 1:Go to Database>>Schema Browser option.The following window will appear.Select the Treeview from the Browser Style.

  • 8/10/2019 Oracle TOAD Lab Guide

    39/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 39 of 85

    The following window will appear.

  • 8/10/2019 Oracle TOAD Lab Guide

    40/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 40 of 85

    Step 2:

    Expand My Schema tab

    Step 3:To see the existing Stored Procedures expand the tab of Procedure.

  • 8/10/2019 Oracle TOAD Lab Guide

    41/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 41 of 85

    Step 4:

    Right click on the Procedure Tab and go for View/Edit package save option

  • 8/10/2019 Oracle TOAD Lab Guide

    42/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 42 of 85

    Step 5:

    Go for the first procedure tab file path

  • 8/10/2019 Oracle TOAD Lab Guide

    43/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 43 of 85

    Step 6:

    Click on edit file and the file opensWith the following code

    CREATE OR REPLACE PROCEDURE %YourObjectname% IStmpVar NUMBER;/******************************************************************************

    NAME: %YourObjectName%PURPOSE:

    REVISIONS:Ver Date Author Description

    --------- ---------- --------------- ------------------------------------1.0 %SYSDATE% %USERNAME% 1. Created this procedure.

    NOTES:

    Automatically available Auto Replace Keywords:Object Name: %YourObjectName%Sysdate: %SYSDATE%Date and Time: %DATE%, %TIME%, and %DATETIME%

  • 8/10/2019 Oracle TOAD Lab Guide

    44/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 44 of 85

    Username: %USERNAME% (set in TOAD Options, Procedure Editor)Table Name: %TableName% (set in the "New PL/SQL Object" dialog)

    ******************************************************************************/BEGIN

    tmpVar := 0;

    EXCEPTIONWHEN NO_DATA_FOUND THENNULL;

    WHEN OTHERS THEN-- Consider logging the error and then re-raiseRAISE;

    END %YourObjectName%;

    Step 6:Let the file remain openThen click on add to add a new SP template

    Step 8:

    Fill in the following details

  • 8/10/2019 Oracle TOAD Lab Guide

    45/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 45 of 85

    Path will be the same as old Procedure template path and name of file will be the name ofthe new SP template.

    Step 9:Try editing the new file.The following screen appears.Click on yes to save the file,as it does not exist it will create a new file with this name andsave it.

  • 8/10/2019 Oracle TOAD Lab Guide

    46/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 46 of 85

    Step 10:

    Copy the contents of the old Procedure template in this new file with the following changeshighlighted in blue color

    CREATE OR REPLACE PROCEDURE %YourObjectname%(pNum1 In number,pNum2 IN Number,pRes Out Number)IStmpVar NUMBER;/******************************************************************************

    NAME: %YourObjectName%

    PURPOSE:

    REVISIONS:Ver Date Author Description--------- ---------- --------------- ------------------------------------1.0 %SYSDATE% %USERNAME% 1. Created this procedure.

    NOTES:

  • 8/10/2019 Oracle TOAD Lab Guide

    47/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 47 of 85

    Automatically available Auto Replace Keywords:Object Name: %YourObjectName%Sysdate: %SYSDATE%Date and Time: %DATE%, %TIME%, and %DATETIME%Username: %USERNAME% (set in TOAD Options, Procedure Editor)Table Name: %TableName% (set in the "New PL/SQL Object" dialog)

    ******************************************************************************/BEGIN

    tmpVar := 0;EXCEPTIONWHEN NO_DATA_FOUND THENNULL;

    WHEN OTHERS THEN-- Consider logging the error and then re-raiseRAISE;

    END %YourObjectName%;

    Step 11:

    Apply the changes and say ok.Now this will be the new Procedure template in addition to the old procedure template.

    Step 12:

    Now Come back to the schema browser and right click on the procedure tab to create a newSP.

  • 8/10/2019 Oracle TOAD Lab Guide

    48/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 48 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    49/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 49 of 85

    Step 13:

    Fill in the following details and choose the new proc template as directed below.

  • 8/10/2019 Oracle TOAD Lab Guide

    50/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 50 of 85

    Step 14:

    Save it.After this the following screen would appear.

  • 8/10/2019 Oracle TOAD Lab Guide

    51/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 51 of 85

    Complete the procedure body by adding the following stmt in it.

    pRes:=pNum1 +pNum2;

    Now execute the procedure by pressing F11

    Step 15:

    After the Procedure is created, create an anonymous block for calling it.declare

    Result number;

    begin

    TryProc(&a,&b,Result);

    dbms_output.put_line('The result is'||Result);end;

    Step 16:Now execute this SP.Set serveroutput on.It will ask for 2 inputs at the run timeSupply the following data

  • 8/10/2019 Oracle TOAD Lab Guide

    52/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 52 of 85

    Step 17:

    After execution the following output will appear in the output window.

  • 8/10/2019 Oracle TOAD Lab Guide

    53/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 53 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    54/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 54 of 85

    Assignment 5Objective:To learn how to use Debug options of TOAD

    Step 1:

    In TOAD Select DatabaseSchema BrowserSelect Procedures from Schema Browser

    Step 2:Select the Procedure to be debugged.

  • 8/10/2019 Oracle TOAD Lab Guide

    55/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 55 of 85

    Step 3:

    As shown in the figure below, load the procedure in the Procedure editor.

  • 8/10/2019 Oracle TOAD Lab Guide

    56/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 56 of 85

    Once it is loaded, you can see a new window for the procedure editor.

  • 8/10/2019 Oracle TOAD Lab Guide

    57/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 57 of 85

    Step 4:Before using any debug options, we need to set the values for input parameters of the

    procedure selected. In Debug menu select Set Parameters options.

  • 8/10/2019 Oracle TOAD Lab Guide

    58/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 58 of 85

    Step 5 :Now you can see a new window opened and the parameters of the procedure are listed. One

    by one we need to set the values for all IN and INOUT parameters. The following picturesillustrate this method for two input parameters (pNum1 and pNum2).

  • 8/10/2019 Oracle TOAD Lab Guide

    59/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 59 of 85

    Step 6:Once the parameters are set with the values, the procedure is ready for debug operation.Here we will see how to set a break point. Go to Debug menu in Procedure editor, and selectSet Breakpoint option after placing the cursor in the appropriate line. Debug SetBreakpoint.

  • 8/10/2019 Oracle TOAD Lab Guide

    60/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 60 of 85

    Once the Breakpoint is set, it will be highlighted with a red line, as shown below.

  • 8/10/2019 Oracle TOAD Lab Guide

    61/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 61 of 85

    Step 7:We can add watches too. Go to Debug menu and select Watches option.

  • 8/10/2019 Oracle TOAD Lab Guide

    62/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 62 of 85

    The Watch window will be opened as shown below. Here, select the add watch optionavailable in the watch window. (See the below snap shot)

  • 8/10/2019 Oracle TOAD Lab Guide

    63/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 63 of 85

    Once you click on Add watch option, a window will be popped and it will prompt forexpression to be watched. Type an expression, or variable to be watched. The following snap

    shots illustrate, to add watches for variables pNum1 and pNum2.

  • 8/10/2019 Oracle TOAD Lab Guide

    64/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 64 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    65/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 65 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    66/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 66 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    67/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 67 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    68/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 68 of 85

    Please find below, the snap shot to display the added watch variables in the watch window.(It shows process not accessible because we have not yet started the debug/ trace operation)

  • 8/10/2019 Oracle TOAD Lab Guide

    69/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 69 of 85

    Step 8:

    Now we can start tracing the execution of the procedure. Go to Debug menu and select TraceInto option. DebugTrace Into.

  • 8/10/2019 Oracle TOAD Lab Guide

    70/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 70 of 85

    It will prompt with the following message Do you want to compile referenced objects withDebug information? This process can take several seconds. Click on Yes.

  • 8/10/2019 Oracle TOAD Lab Guide

    71/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 71 of 85

    The Tracing is started and it will show the tracing line with highlighted color.

  • 8/10/2019 Oracle TOAD Lab Guide

    72/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 72 of 85

    Every time press shift+F7 or select the Trace Into option from Debug menu.

  • 8/10/2019 Oracle TOAD Lab Guide

    73/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 73 of 85

    While tracing the procedure execution, we can watch the variables added for watch option inthe watch window.

  • 8/10/2019 Oracle TOAD Lab Guide

    74/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 74 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    75/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 75 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    76/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 76 of 85

    Assignment 6Objective:To learn how to use the DBMS output window of SQL Editor.

    The following demo is to show the use of DBMS Output window available in SQL Editor ofTOAD.

    Step 1:Type the following code in SQL Editor, as given in the snap shot. Click on DBMS Outputwindow, and click on the clear window button.

  • 8/10/2019 Oracle TOAD Lab Guide

    77/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 77 of 85

    Step 2:Click on the Turn Output On button as shown in the below snap shot.

  • 8/10/2019 Oracle TOAD Lab Guide

    78/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 78 of 85

  • 8/10/2019 Oracle TOAD Lab Guide

    79/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 79 of 85

    Step 3:Go to Debug menu and select the Run option.

  • 8/10/2019 Oracle TOAD Lab Guide

    80/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 80 of 85

    Once you Run the script, the DBMS Output window will show the output.

  • 8/10/2019 Oracle TOAD Lab Guide

    81/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 81 of 85

    Assignment 7Objective:To learn how to use the CodeXpert option of SQL Editor.

    Step 1:Type the following query in SQL Editor.

    Select emp.empno, emp.deptno, dept.dname from emp, dept;

  • 8/10/2019 Oracle TOAD Lab Guide

    82/85

  • 8/10/2019 Oracle TOAD Lab Guide

    83/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 83 of 85

    Step2 :

    Select CodeXpert window and click on button available in CodeXpert window.

  • 8/10/2019 Oracle TOAD Lab Guide

    84/85

    ORACLEExercises for Hands on

    ER/COPR/CRS/DB46SC/019 Education & Research Department Infosys Technologies Limited 84 of 85

    Now we can see the suggestions given by CodeXpert in the bottom window.

  • 8/10/2019 Oracle TOAD Lab Guide

    85/85

    ORACLEExercises for Hands on