0% found this document useful (0 votes)
48 views

Overview of PL/SQL: Ibm Solutions Delivery Inc

Uploaded by

avramos
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Overview of PL/SQL: Ibm Solutions Delivery Inc

Uploaded by

avramos
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

®

IBM SOLUTIONS DELIVERY INC.

Overview of PL/SQL

Prepared by:

Sherwin O. Bautista

© 2008 IBM Corporation


IBM SOLUTIONS DELIVERY INC.

Course Objectives

After completing this course, trainees should be able to do the


following:

Describe the purpose of PL/SQL

Describe the use of PL/SQL for the developer as well as the DBA

Will be able to explain benefits of PL/SQL

Create, execute, and maintain procedure functions, packages, and


database triggers.

2
IBM SOLUTIONS DELIVERY INC.

About PL/SQL

PL/SQL (Procedural Languages/SQL)


 Oracle Corporation’s procedure language extension to SQL.

 the standard data access language for relational databases.

 Offers modern software engineering features such as:


•data encapsulation,
•exception handling,
•Information hiding,
•Object orientation,
•and brings state-of-the-art programming to the Oracle Server and tool set.

 It allows the data manipulation and query statements of SQL to be included in


block-structured and procedural units of code.

3
IBM SOLUTIONS DELIVERY INC.

PL/SQL Environment

PL/SQL Engine Oracle Server


PL/SQL Procedural Statement
Block Executor
PL/SQL
Block SQL Executor Statements

When a user submit PL/SQL blocks from program (i.e. Pro*COBOL, Pro*C) or
other tools (i.e iSQL*Plus), the PL/SQL engine in the Oracle Server process the
PL/SQL blocks. It separates the SQL statements and sends them individually to
the SQL statement executor.

4
IBM SOLUTIONS DELIVERY INC.

Benefits of PL/SQL
Integration:
PL/SQL plays a central role in both the Oracle Server (through stored procedures, stored
functions, database triggers, and packages) and Oracle Development tools.

SQL data types can also be used in PL/SQL. PL/SQL bridges the gap between convenient
access to database technology and the need for procedural programming capabilities.

Improved Performance:
PL/SQL can improved the performance of an application. The benefits differ depending on
the execution environment.

 It helps reduce network traffic because PL/SQL can used to group SQL
statements together within a single block and to send the block to the
server in a single call.

 PL/SQL can also operate with Oracle Server application development


tools such as Oracle Forms and Oracle Reports. PL/SQL enhances
performance by adding procedural processing power using Oracle Server
application development tools.
5
IBM SOLUTIONS DELIVERY INC.

Benefits of PL/SQL
Modularize program development:

DECLARE

{code .... } PL/SQL Block Structure

BEGIN Every unit of PL/SQL contains one or more


blocks. The basic units (procedures, functions,
{code….} anonymous block) that make up a PL/SQL program
are logical blocks, which contains any number of
EXCEPTION nested subblocks.

{code….} One block can represent a small part of


another block, which in turn can be a part of the
END; whole unit of code.

6
IBM SOLUTIONS DELIVERY INC.

Benefits of PL/SQL
Portability:
PL/SQL is native to the Oracle Server, a programs can be moved to any host environment
(operating system or platform) that support the Oracle Server and PL/SQL.

Identifiers:
PL/SQL can used identifiers to do the following:

Declare variables, cursors, constants, and exceptions and then use them in SQL and
procedural statements.

 Declare variables belonging to scalar, reference, composite, and large object (LOB) data
types.

 Declare variables dynamically based on the data structure of tables and columns in the
database.

7
IBM SOLUTIONS DELIVERY INC.

Benefits of PL/SQL

Procedural Language Control Structures:

 Execute a sequence of statements conditionally

 Execute a sequence of statements iteratively in a loop

 Process individually the rows returned by a multiple-row query with an explicit


cursor

Errors: (PL/SQL can handle errors)

 Process Oracle server errors with exception-handling routines

Declare user-define error conditions and process them with exception-handling


routines.

8
IBM SOLUTIONS DELIVERY INC.

Benefits of Subprograms
Easy maintenance:
 Routines online without interfering with other users.

 One routine to affect multiple applications.

 One routine to eliminate duplicating testing.

Improved data security and integrity:

 Control indirect access to database objects from non-privileged users with security
privileges

 Ensure that related actions are performed together, or not at all, by funneling activity
for related tables through a single path.

9
IBM SOLUTIONS DELIVERY INC.

Benefits of Subprograms
Improved performance:
 Avoid reparsing for multiple users by exploiting the shared SQL area

 Avoid PL/SQL parsing at run time by parsing at compilation time.

 Reduce the number of calls to the database and decrease network traffic by
bundling commands.

Improved code clarity:

 Using appropriate identifier names to describe the action of the routines reduces the
need for comments and enhances the clarity of the code.

10
IBM SOLUTIONS DELIVERY INC.

http://www.ibm.com/software/data/db2

11

You might also like