Creating Program Units by Using Procedure Builder

C

Copyright © Oracle Corporation, 2001. All rights reserved.

Objectives
After completing this appendix, you should be able to do the following:

• • • • • • •
C-2

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

Copyright © Oracle Corporation, 2001. All rights reserved.

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

Tools Constructs
Anonymous blocks Application procedures or functions Application packages Application triggers Object types

END;

Database Server Constructs
Anonymous blocks Stored procedures or functions Stored packages Database triggers 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 Object Navigator PL/SQL Interpreter Program Unit Editor Stored Program Unit Editor Database Trigger Editor Function Manages PL/SQL constructs; performs debug actions Debugs PL/SQL code; evaluates PL/SQL code in real time Creates and edits PL/SQL source code Creates and edits server-side PL/SQL source code 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 code Server-side code

Program units in a PL/SQL library

Stored program units in the Oracle server

C-8

Copyright © Oracle Corporation, 2001. All rights reserved.

Procedure Builder Components: The Object Navigator
1 2 3 4 5

C-9

Copyright © Oracle Corporation, 2001. All rights reserved.

Procedure Builder Components: The Object Navigator

1 2 3 4

C-10

Copyright © Oracle Corporation, 2001. All rights reserved.

Procedure Builder Components: Objects of the Navigator

Program Units
– – – Specification References Referenced By

• • • • • •
C-11

Libraries Attached Libraries Built-in Packages Debug Actions Stack Database Objects

Copyright © Oracle Corporation, 2001. All rights reserved.

Developing Stored Procedures
Oracle Procedure Builder Code

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 3

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

1

5 4

2 3

C-15

Copyright © Oracle Corporation, 2001. All rights reserved.

Creating a Server-Side Program Unit

5 4

1 2 3

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

1

2

3

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
1000 TAX

function
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

1

2

3

C-31

Copyright © Oracle Corporation, 2001. All rights reserved.

Setting a Breakpoint

1

2

C-32

Copyright © Oracle Corporation, 2001. All rights reserved.

Debug Commands
Step Over

Step Into

Reset

Step Out

Go

C-33

Copyright © Oracle Corporation, 2001. All rights reserved.

Stepping through Code

1

2

3

C-34

Copyright © Oracle Corporation, 2001. All rights reserved.

Changing a Value

4

1 2

3

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 Object Navigator Program Unit Editor PL/SQL Interpreter Debugger

Describe the components of Procedure Builder
– – – –

C-36

Copyright © Oracle Corporation, 2001. All rights reserved.

Sign up to vote on this title
UsefulNot useful