Unit-3 (Stored procedures and User defined functions)
PL/SQL Basics Introduction
Introduction
Programming language/structured query language
It provide facility of procedural and function
It provides programming techniques like branching, looping, and condition check.
It is fully structured programming language.
It decreases the network traffic because entire block of code is passed to the DBA at one
time for execution.
Basic Structure of PL/SQL
PL/SQL stands for Procedural Language/SQL. PL/SQL extends SQL by adding
constructs found in procedural languages, resulting in a structural language that is
more powerful than SQL. The basic unit in PL/SQL is a block. All PL/SQL programs are
made up of blocks, which can be nested within each other. Typically, each block
performs a logical action in he program. A block has the following structure:
DECLARE
/* Declarative section: variables, types, and local subprograms. */
BEGIN
/* Executable section: procedural and SQL statements go here. */
/* This is the only section of the block that is required. */
EXCEPTION
/* Exception handling section: error handling statements go here. */
END;
Advantages of PL/SQL
PL/SQL is development tool that not only supports SQL data manipulation but also provide
facilities of conditional checking, branching and looping.
PL/SQL sends an entire block of statements to the Oracle engine at one time. The
communication between the program block and the Oracle engine reduces considerably. This is
turn reduces network traffic.
PL/SQL also permits dealing with errors as required, and facilitates displaying user-friendly
messages, when errors are encountered.
PL/SQL allows declaration and use of variables in blocks of code. These variables can be
used to store intermediate results of a query for later processing, or calculate values and
insert them into an Oracle table later. PL/SQL variables can be used anywhere, either in
SQL statements or in PL/SQL blocks.
Support for SQL
Support for object-oriented programming
Better performance
Higher productivity
Full portability
Tight integration with Oracle
Tight security