Sei sulla pagina 1di 36

C

Creating Program Units by Using


Procedure Builder

Copyright © Oracle Corporation, 2001. All rights reserved.


Objectives

After completing this appendix, you should be able to


do the following:
• Describe the features of Oracle Procedure Builder
• Manage program units using the Object Navigator
• Create and compile program units using the
Program Unit Editor
• Invoke program units using the PL/SQL Interpreter
• Debug subprograms using the debugger
• Control execution of an interrupted PL/SQL
program unit
• Test possible solutions at run time

C-2 Copyright © Oracle Corporation, 2001. All rights reserved.


PL/SQL Program Constructs
<header> IS|AS
or DECLARE

BEGIN

EXCEPTION
Database Server
Tools Constructs Constructs
Anonymous blocks END;
Anonymous blocks
Application procedures or
Stored procedures or
functions
functions
Application packages
Stored packages
Application triggers
Database triggers
Object types
Object types

C-3 Copyright © Oracle Corporation, 2001. All rights reserved.


Development Environments

• iSQL*Plus uses the PL/SQL engine in the Oracle


Server
• Oracle Procedure Builder uses the PL/SQL engine
in the client tool or in the Oracle Server. It
includes:
– A GUI development environment for PL/SQL code
– Built-in editors
– The ability to compile, test, and debug code
– Application partitioning that allows drag-and-drop
of program units between client and server

C-4 Copyright © Oracle Corporation, 2001. All rights reserved.


Developing Procedures and Functions
Using iSQL*Plus

C-5 Copyright © Oracle Corporation, 2001. All rights reserved.


Developing Procedures and Functions Using
Oracle Procedure Builder

C-6 Copyright © Oracle Corporation, 2001. All rights reserved.


Components of
Procedure Builder
Component Function
Object Navigator Manages PL/SQL constructs;
performs debug actions
PL/SQL Interpreter Debugs PL/SQL code; evaluates
PL/SQL code in real time
Program Unit Editor Creates and edits PL/SQL source
code
Stored Program Creates and edits server-side
Unit Editor PL/SQL source code
Database Trigger Editor Creates and edits database triggers

C-7 Copyright © Oracle Corporation, 2001. All rights reserved.


Developing Program Units
and Stored Programs Units
Procedure
Builder
Client-side Server-side
code code

Program units Stored program units


in a PL/SQL library in the Oracle server

C-8 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
The Object Navigator

1 5
2
3 4

C-9 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
The Object Navigator

C-10 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
Objects of the Navigator

• Program Units
– Specification
– References
– Referenced By
• Libraries
• Attached Libraries
• Built-in Packages
• Debug Actions
• Stack
• Database Objects

C-11 Copyright © Oracle Corporation, 2001. All rights reserved.


Developing Stored Procedures

Oracle Code
Procedure
Builder
Compile and Save

Oracle Source code

P code

Execute

C-12 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
The Program Unit Editor

1
2

C-13 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
The Stored Program Unit Editor

C-14 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating a Client-Side
Program Unit

5
1
4

C-15 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating a Server-Side
Program Unit

1 4

C-16 Copyright © Oracle Corporation, 2001. All rights reserved.


Transferring Program Units Between
Client and Server

C-17 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Components:
The PL/SQL Interpreter

C-18 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating Client-Side Program Units

C-19 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating Server-Side Program Units

Create
Delete

C-20 Copyright © Oracle Corporation, 2001. All rights reserved.


The DESCRIBE Command in
Procedure Builder

C-21 Copyright © Oracle Corporation, 2001. All rights reserved.


Listing Code of Stored Program Units

Stored
procedure
icon
Expand
and
Collapse
buttons

C-22 Copyright © Oracle Corporation, 2001. All rights reserved.


Navigating Compilation Errors
in Procedure Builder

C-23 Copyright © Oracle Corporation, 2001. All rights reserved.


Procedure Builder Built-in Package:
TEXT_IO

• The TEXT_IO package:


– Contains a procedure PUT_LINE, which writes
information to the PL/SQL Interpreter window
– Is used for client-side program units
• The TEXT_IO.PUT_LINE accepts one parameter

PL/SQL> TEXT_IO.PUT_LINE(1);
1

C-24 Copyright © Oracle Corporation, 2001. All rights reserved.


Executing Functions in
Procedure Builder: Example
Calling environment TAX function
1000 v_value

RETURN (computed value)

Display the tax based on a specified value.

PL/SQL> .CREATE NUMBER x PRECISION 4


PL/SQL> :x := tax(1000);
PL/SQL> TEXT_IO.PUT_LINE (TO_CHAR(:x));
80

C-25 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating Statement Triggers

C-26 Copyright © Oracle Corporation, 2001. All rights reserved.


Creating Row Triggers

C-27 Copyright © Oracle Corporation, 2001. All rights reserved.


Removing Server-Side Program Units

Using Procedure Builder:


1. Connect to the database.
2. Expand the Database Objects node.
3. Expand the schema of the owner of the program unit.
4. Expand the Stored Program Units node.
5. Click the program unit that you want to drop.
6. Click Delete in the Object Navigator.
7. Click Yes to confirm.

C-28 Copyright © Oracle Corporation, 2001. All rights reserved.


Removing Client-Side
Program Units

Using Procedure Builder:


1. Expand the Program Units node.
2. Click the program unit that you want to remove.
3. Click Delete in the Object Navigator.
4. Click Yes to confirm.

C-29 Copyright © Oracle Corporation, 2001. All rights reserved.


Debugging Subprograms by Using
Procedure Builder

C-30 Copyright © Oracle Corporation, 2001. All rights reserved.


Listing Code in the Source Pane

C-31 Copyright © Oracle Corporation, 2001. All rights reserved.


Setting a Breakpoint

C-32 Copyright © Oracle Corporation, 2001. All rights reserved.


Debug Commands

Step Over

Reset
Step
Into

Step Out

Go

C-33 Copyright © Oracle Corporation, 2001. All rights reserved.


Stepping through Code

C-34 Copyright © Oracle Corporation, 2001. All rights reserved.


Changing a Value

1
2

C-35 Copyright © Oracle Corporation, 2001. All rights reserved.


Summary

In this appendix, you should have learned how to:


• Use Procedure Builder:
– Application partitioning
– Built-in editors
– GUI execution environment
• Describe the components of Procedure Builder
– Object Navigator
– Program Unit Editor
– PL/SQL Interpreter
– Debugger

C-36 Copyright © Oracle Corporation, 2001. All rights reserved.

Potrebbero piacerti anche