0% found this document useful (0 votes)
44 views20 pages

16CSS14 Oracle - Group VIII Map Code: F Faculty: B.DEEPA Department of Information Technology

This document is a lesson plan on PL/SQL from B.Deepa of the Department of Information Technology. It covers the need for and benefits of PL/SQL, the different types of PL/SQL blocks, and outputting messages. Key points include that PL/SQL seamlessly integrates procedural logic with SQL, provides benefits like improved performance and exception handling, and blocks must have a declarative, executable, and optional exception section. The document also demonstrates creating and running a simple anonymous PL/SQL block.

Uploaded by

Tharani Tharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views20 pages

16CSS14 Oracle - Group VIII Map Code: F Faculty: B.DEEPA Department of Information Technology

This document is a lesson plan on PL/SQL from B.Deepa of the Department of Information Technology. It covers the need for and benefits of PL/SQL, the different types of PL/SQL blocks, and outputting messages. Key points include that PL/SQL seamlessly integrates procedural logic with SQL, provides benefits like improved performance and exception handling, and blocks must have a declarative, executable, and optional exception section. The document also demonstrates creating and running a simple anonymous PL/SQL block.

Uploaded by

Tharani Tharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

16CSS14

Oracle –Group VIII


Map Code: F
Faculty: B.DEEPA
Department of Information Technology

B.Deepa UNIT IV Hour 30


1
B.Deepa UNIT IV Hour 30 2
Department of Information Technology

 After completing this lesson, you should be able to do


the following:
 Explain the need for PL/SQL
 Explain the benefits of PL/SQL
 Identify the different types of PL/SQL blocks
 Output messages in PL/SQL

B.Deepa UNIT IV Hour 30 3


Department of Information Technology

 PL/SQL:
 Stands for “Procedural Language extension to SQL”
 Is Oracle Corporation’s standard data access language for
relational databases
 Seamlessly integrates procedural constructs with SQL

B.Deepa UNIT IV Hour 30 4


Department of Information Technology

 PL/SQL:
 Provides a block structure for executable units of
code. Maintenance of code is made easier with such a
well-defined structure.
 Provides procedural constructs such as:
 Variables, constants, and data types
 Control structures such as conditional statements and loops
 Reusable program units that are written once and executed
many times

B.Deepa UNIT IV Hour 30 5


PL/SQL engine

procedural Procedural
PL/SQL statement
block executor
SQL

SQL statement
executor

Oracle database server

B.Deepa UNIT IV Hour 30 6


Department of Information Technology

 Integration of procedural constructs with SQL


 Improved performance

SQL 1
SQL 2

SQL
IF...THEN
SQL
ELSE
SQL
END IF;
SQL

B.Deepa UNIT IV Hour 30 7


Department of Information Technology

 Modularized program development


 Integration with Oracle tools
 Portability
 Exception handling

B.Deepa UNIT IV Hour 30 8


Department of Information Technology

 DECLARE (optional)
 Variables, cursors, user-defined exceptions
 BEGIN (mandatory)
 SQL statements
 PL/SQL statements
 EXCEPTION (optional)
 Actions to perform
when errors occur
 END; (mandatory)

B.Deepa UNIT IV Hour 30 10


Department of Information Technology

 Anonymous Procedure
Function

[DECLARE] PROCEDURE name FUNCTION name


IS RETURN datatype
IS
BEGIN BEGIN BEGIN
--statements --statements --statements
RETURN value;
[EXCEPTION] [EXCEPTION] [EXCEPTION]

END; END; END;

B.Deepa UNIT IV Hour 30 12


Database Server
Tools Constructs Constructs
Anonymous blocks Anonymous blocks
Application procedures Stored procedures or
or functions functions

Application packages Stored packages

Application triggers Database triggers

Object types Object types

B.Deepa UNIT IV Hour 30 14


Department of Information Technology

 Enter the anonymous block in the SQL Developer workspace:

B.Deepa UNIT IV Hour 30 16


Department of Information Technology

 Click the Run Script button to execute the anonymous block:

Run Script

B.Deepa UNIT IV Hour 30 17


Department of Information Technology

 Enable output in SQL Developer by clicking the Enable


DBMS Output button on the DBMS Output tab:
Enable DBMS
Output 1

2
DBMS Output
Tab

 Use a predefined Oracle package and its procedure:


 DBMS_OUTPUT.PUT_LINE

DBMS_OUTPUT.PUT_LINE(' The First Name of the


Employee is ' || v_fname);

B.Deepa UNIT IV Hour 30 18


B.Deepa UNIT IV Hour 30 19
Department of Information Technology

 Modularized program development


 Integration with Oracle tools
 Portability
 Exception handling
 Anonymous blocks

B.Deepa UNIT IV Hour 30 20


Department of Information Technology

 A PL/SQL block must consist of the following


three sections:
1. A Declarative section which begins with the
keyword DECLARE and ends when the
executable section starts.
2. An Executable section which begins with the
keyword BEGIN and ends with END.
3. An Exception handling section which begins with
the keyword EXCEPTION and is nested within
the executable section.
a) True
b) False

B.Deepa UNIT IV Hour 30 21


Department of Information Technology

 Integration of procedural constructs with SQL


 Improved performance
 Modularized program development
 Integration with Oracle tools
 Portability
 Exception handling

B.Deepa UNIT IV Hour 30 22


Department of Information Technology

 In this lesson, you should have learned how to:


 Integrate SQL statements with PL/SQL program constructs
 Describe the benefits of PL/SQL
 Differentiate between PL/SQL block types
 Output messages in PL/SQL`

B.Deepa UNIT IV Hour 30 23


Department of Information Technology

 This practice covers the following topics:


 Identifying the PL/SQL blocks that execute successfully
 Creating and executing a simple PL/SQL block

B.Deepa UNIT IV Hour 30 24

You might also like