Stored Program Unit Editor Create and edit server-side PL/SQL source code.. Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć16The Object Navigator Vertical Button Bar..
Trang 1Basics of Procedure Builder
19
Trang 2Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć2
Class Management Note:
If using SQL*Plus instead of Procedure Builder, replace this lesson withAppendix C
Files required for this lesson:
Demonstration: l19loop.pls
Practice: p19loop.pls
Trang 3Basics of Procedure Builder 19Ć3
Objectives
A key feature of procedural programming is the ability to create and debug code quickly and easily Procedure Builder provides all of the functionality necessary for you to successfully develop and debug PL/SQL programs This lesson
enables you to manipulate PL/SQL code using Procedure Builder.
At the end of this lesson, you should be able to
D Identify the advantages of developing and debugging PL/SQL programs in
Procedure Builder
D Manage program units by using the Object Navigator
D Execute program units and SQL statements by using the PL/SQL Interpreter
D Define and compile procedures by using the Program Unit editor
D Define and compile database procedures by using the Stored Program Unit editor
D Set a breakpoint to suspend program execution
D Control the execution of an interrupted PL/SQL program unit
D Test possible solutions by changing variables and procedures at runtime
Trang 4Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć4
Trang 5Basics of Procedure Builder 19Ć5
by learning about each component’s function Once you are familiar with the
Procedure Builder environment, you will cover the PL/SQL syntax
Procedure Builder Features
Object Navigator Manage PL/SQL constructs
Perform debug actions
PL/SQL Interpreter Debug PL/SQL code
Evaluate PL/SQL code in real time
Program Unit Editor Create and edit PL/SQL source code
Stored Program Unit
Editor
Create and edit server-side PL/SQL source code
Database Trigger Editor Create and edit database triggers
For more information, see
Oracle Procedure Builder Developer’s Guide, Release 1.5.
Class Management Note:
This lesson is designed to give students an overview of the ProcedureBuilder product The actual syntax will be covered in the following lessons.The focus of this lesson should be how to use the product
Trang 6Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć6
Procedural Programming Capabilities
Trang 7Basics of Procedure Builder 19Ć7
Oracle Procedure Builder Capabilities
Procedure Builder is an integrated, interactive environment that you can use to create,execute, and debug PL/SQL programs Using Procedure Builder, you can buildportable database programs quickly and easily
Integrated PL/SQL Development Environment
D Create and edit subprograms
D Compile subprograms to perform syntactical error checking
D Test subprograms
D Debug subprograms
Unified ClientĆServer PL/SQL Development
D Create database triggers
D Create stored procedures and move them to the client to debug
D Build and edit client-side libraries
D Create client-side program units and move them to the server
Class Management Note:
After you debug program units, move them to the server so all applicationscan access them Server-side debugging through Procedure Builder will beavailable in release 2.0
Trang 8Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć8
Procedure Builder Components
Procedure Builder Components
Trang 9Basics of Procedure Builder 19Ć9
Procedure Builder Components
The Object Navigator
The Object Navigator provides an outline style interface to browse objects, view therelationships between them, and edit their properties
The Interpreter
The Interpreter is the central debugging workspace of Procedure Builder It is atwo-pane window where you display, debug, and run PL/SQL program units It alsointeractively supports the evaluation of PL/SQL constructs, SQL commands, andProcedure Builder commands
The Program Unit Editor
The easiest and most common place to enter PL/SQL source code is in the ProgramUnit editor You can use it to edit, compile, and browse warning and error messagesduring application development
The Stored Program Unit Editor
The Stored Program Unit editor is a GUI environment for editing server-side
packages and subprograms The compile operation submits the source text to theserver-side PL/SQL compiler To debug server-side program units you can drag acopy of the program unit to the client side using the Object Navigator
The Database Trigger Editor
The Database Trigger editor is a GUI environment for editing database triggers Thecompile operation submits the source text to the server-side PL/SQL compiler
Online Help
Oracle Procedure Builder has a help facility that provides assistance at any timeduring your session You can access it from the menu bar
Class Management Note:
Do not explain the functioning of procedures or functions In this lesson,students just need to understand the various components of ProcedureBuilder Details of procedures and functions will be covered in the nextlesson
Trang 10Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć10
Using the Quick Tour
Class Management Note:
DEMO
PURPOSE: Familiarize students with Quick Tour
Access the Quick Tour from the Help menu Demonstrate how to accessone of the topics
Trang 11Basics of Procedure Builder 19Ć11
Using the Quick Tour
The Quick Tour, another type of online help, introduces you to product terminology,
workflow, and theoretical concepts This is an excellent resource to get started withProcedure Builder You can invoke the Quick Tour by choosing the Quick Tour menuitem from the Help menu
Procedure Builder Basics
Become familiar with the Object Navigator to create and manage your PL/SQLobjects Also, learn the terminology used in the Object Navigator
Developing a Program Unit
Review each step to develop a program unit Create, edit, and compile a PL/SQLprogram unit using the Program Unit and Database Trigger editors
Debugging a Program Unit
This section describes how to debug a program unit using the PL/SQL Interpreter Itdescribes how to set breakpoints, step through your code, and peruse the Stack node
to change the value of the variable
Organizing PL/SQL
Step through application partitioning between the client and server, including usinglibraries and moving subprograms between the client and server
Procedure Builder Features
Review the kinds of application-building tasks you can perform using ProcedureBuilder
Trang 12Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć12
Using Cue Cards
Class Management Note:
DEMO
PURPOSE: Familiarize students with Cue Cards
Access the Cue Cards from the Help menu Click on the Learn
About—>Cue Cards Tell Me button Demonstrate each button type
Navigate one of the topics
Trang 13Basics of Procedure Builder 19Ć13
Using Cue Cards
Developer/2000 provides further help in the form of Cue Cards Their purpose is toprovide just-in-time coaching for frequently performed tasks You can invoke CueCards by selecting the Cue Cards menu item from the Help menu
Cue cards contain two types of content: task and concept Task cards list the steps tocomplete a task, while concept cards describe a particular concept with static
graphics When invoked, Cue Cards display a list of topics that are divided into twocategories:
D Task: What would you like to do?
D Concept: Learn About
To display the cue card for any of these topics, click the appropriate button to the left
of the item
Cue Cards include a set of six buttons that you use to navigate to the information yourequire
Next Card Advance one card
Back Return to the previous card
Tell Me Obtain more information about a topic
Show Me View a short movie or animation on a task
Options Set Cue Card options
Exit Exit Cue Cards
Trang 14Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć14
Navigator drop down list
Object name
Trang 15Basics of Procedure Builder 19Ć15
The Object Navigator
The Object Navigator provides immediate access to every object in your developmentenvironment You can create and manipulate all of your PL/SQL program units,libraries, debug actions, and variables from the Object Navigator
Object Navigator Components
Navigator drop down list Indicates the name of the currently selected object.Subobject indicator Indicates whether an object can be expanded to view
its subobjects
Type icon Indicates the object type
Object name Indicates the name of the object
Find field Used to search for a named object
Trang 16Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć16
The Object Navigator Vertical Button Bar
Trang 17Basics of Procedure Builder 19Ć17
The Object Navigator Vertical Button Bar
The Vertical Button Bar on the Object Navigator provides a convenient access formany of the actions frequently performed from the File, Edit, and Navigator menus
Elements of the Vertical Button Bar
Open Opens a library from the file system or from the Oracle7 Server.Save Saves a library on the file system or on the Oracle7 Server
Cut Cuts the selected object and stores it in the clipboard Cutting an
object also cuts any objects owned by that object
Copy Makes a copy of the selected object and stores it in the clipboard
Copying an object also copies any objects owned by that object.Paste Pastes the cut or copied module into the selected location Note
that objects must be copied to a valid location in the objecthierarchy
Create Creates a new instance of the currently selected object
Delete Deletes the selected object with confirmation
Expand Expands the first level of subobjects of the currently selected
Trang 18Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć18
Objects of the Navigator
Class Management Note:
DEMO: Identify all these items in the Object Navigator
Trang 19Basics of Procedure Builder 19Ć19
Object Navigator Objects
By using the Object Navigator, you can display a hierarchical listing of all objectsyou have access to during your session
Program Units PL/SQL construct that can be independently recognized and
processed by the PL/SQL compiler
Libraries Collection of PL/SQL packages, procedures, and functions
stored in the database or the file system
Attached Libraries Referenced libraries stored in the database or the file system.Built-in Packages PL/SQL constructs that can be referenced while debugging
program units
Debug Actions Actions that enable you to monitor or interrupt the execution
of PL/SQL program units
Stack Chain of subprogram calls, from the initial entry point down
to the currently executing subprogram
Database Objects Collection of server-side stored program units, libraries,
tables, and views
Trang 20Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć20
Class Management Note:
DEMO: Expand and collapse the database objects node
Trang 21Basics of Procedure Builder 19Ć21
Managing Objects Using the Object Navigator
Use the Vertical Button Bar and the Find Field on the Object Navigator to managePL/SQL constructs, debug actions, and database objects
Creating a Library
1. Select the Libraries object
2. Click the Create button.
The new library subobject will appear with a default name
Saving a Library
1. Select the Library to save
2. Select Save As from the File menu.
The Save Library dialog box appears
3. Enter a new name for the library (optional) Choose either the File System or theDatabase radio button Click the OK button to accept the options
Expanding a Node
1. Select a valid node.
2. Click the Expand button or the Expand All button.
Searching for an Object
1. Type the name, full or partial, of the object you wish to find in the Find Field
As soon as you begin typing, any match found starting from the top of the ObjectNavigator is highlighted
2. Click the Search Forward or Search Backward button to find additional matches
of the search criteria in the Object Navigator
Trang 22Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć22
The Interpreter
Trang 23Basics of Procedure Builder 19Ć23
The Interpreter
Using the Interpreter, you can define, display, debug, and run PL/SQL program units.
To display the Interpreter at any time, choose the PL/SQL Interpreter from the Toolsmenu
Interpreter Components
Program execution buttons Enables you to execute the Step Into, Step Over, Step
Out, Go, and Reset buttons
Close button Closes the Interpreter
Source pane Displays a read-only copy of the program unit
currently selected
Interpreter pane Provides a command line interface to PL/SQL and
Procedure Builder
Scroll bar Scrolls the window
Split bar Changes the relative amount of space occupied by each
pane in the Interpreter
Trang 24Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć24
The Interpreter Pane1
23
Class Management Note:
This slide demonstrates how SQL DDL, PL/SQL, and SQL statements can
be evaluated at the Interpreter prompt Procedure Builder commands, such
as INTERPRET (which loads subprogram text from a script file and
compiles it) can also be executed at the Interpreter prompt
Trang 25Basics of Procedure Builder 19Ć25
The Interpreter Pane
Using the Interpreter pane, you can interactively evaluate PL/SQL constructs andSQL commands
From the PL/SQL prompt in the Interpreter pane, you can execute SQL statements.
For example, to select all columns of the B_TEST table, enter the following
statement:
PL/SQL> SELECT * FROM b_test;
Class Management Note:
Students do not need to understand the FOR loop in the above example Theexample is given to show students how the Interpreter pane works
Trang 26Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć26
The Program Unit Editor1
32
Class Management Note:
When invoking the Program Unit editor from the Tools menu, the firstprocedure or function subnode of the Program Units node will be opened, if
it exists Otherwise the Program Unit editor will be empty
Trang 27Basics of Procedure Builder 19Ć27
The Program Unit Editor
Create, edit, and compile PL/SQL source code by using the Program Unit editor
Methods to Display the Program Unit Editor
D Choose Program Unit Editor from the Tools menu
D Double-click the icon of a program unit in the Object Navigator
D Select Program Units in the Object Navigator and click the Create button.
Program Unit Editor Components
Compile button Compiles the program unit appearing in the Source
Text pane
Apply button Saves any changes made to the program unit in the
editor since it was first opened or since the last apply
or revert operation
Revert button Restores the state of the program unit to the last apply
or revert
New button Invokes the New Program Unit dialog box
Delete button Deletes the current program unit (with confirmation).Name drop down list Displays the name and type of the current program
unit You can use the drop down list to select anotherprogram unit to edit
Source Text pane Allows you to enter and edit PL/SQL program unit
Trang 28Introduction to Oracle: SQL and PL/SQL Using Procedure Builder 19Ć28
Creating a Program Unit
21
Create the Program Unit.
Class Management Note:
DEMO
PURPOSE: Create and compile a procedure
Focus on how a procedure is created and compiled rather than on the syntaxand algorithm for creating the procedure
1 Create a procedure named MY_MESSAGE
2 Compile the procedure using the Program Unit editor
3 Add a deliberate error, for example, no semicolon after executable statement to demonstrate how to use the compiler and CompilationMessage pane