Learn PL/SQL in 1 Day: ALL RIGHTS RESERVED. No Part of This Publication May Be Reproduced
Learn PL/SQL in 1 Day: ALL RIGHTS RESERVED. No Part of This Publication May Be Reproduced
By Krishna Rungta
Chapter 16: Oracle PL/SQL Insert, Update, Delete & Select Into
[Example]
1. DML Transactions in PL/SQL
2. Data Insertion
3. Data Update
4. Data Deletion
5. Data Selection
Chapter 17: Oracle PL/SQL Cursor: Implicit, Explicit, Cursor FOR Loop
[Example]
1. What is CURSOR in PL/SQL?
2. Implicit Cursor
3. Explicit Cursor
4. Cursor Attributes
5. FOR Loop Cursor statement
Chapter 21: Oracle PL/SQL Trigger Tutorial: Instead of, Compound [Example]
1. What are Triggers in PL/SQL?
2. Benefits of Triggers
3. Types of Triggers in Oracle
4. How to Create Trigger
5. :NEW and :OLD Clause
6. INSTEAD OF Trigger
7. Compound Trigger
Chapter 24: Nested Blocks & Variable Scope in Oracle PL/SQL Tutorial
[Example]
1. Nested Block Structure
2. Scopes in Nested Block: Variable Scope
Chapter 1: What Is PL/SQL? Introduction &
Architecture
What is PL/SQL?
Architecture of PL/SQL
PL/SQL block:
This is the component which has the actual PL/SQL code. This
consists of different sections to divide the code logically
(declarative section for declaring purpose, execution section for
processing statements, exception handling section for handling
errors)
It also contains the SQL instruction that used to interact with the
database server.
All the PL/SQL units are treated as PL/SQL blocks, and this is the
starting stage of the architecture which serves as the primary input.
Following are the different type of PL/SQL units.
Anonymous Block Function
Library Procedure
Package Body
Package Specification Trigger
Type
Type Body
PL/SQL Engine
Database Server:
This is the most important component of Pl/SQL unit which
stores the data.
The PL/SQL engine uses the SQL from PL/SQL units to interact with
the database server.
It consists of SQL executor which parses the input SQL statements and
execute the same.
Below is the pictorial representation of Architecture of PL/SQL.
SQL T-SQL
SQL is a programming language T-SQL is a procedural extension
which focuses on managing used by SQL Server.
relational databases.
This is used for controlling and T-SQL has some features that are
manipulating data where large not available in SQL. Like
amounts of information are procedural programming
stored about products, clients, elements and a local variable to
etc. provide more flexible control of
how the application flows.
SQL queries submitted T-SQL writes a program in such a
individually to the database way that all commands are
server. submitted to the server in a single
go
The syntax was formalized for It also includes special functions
many commands; some of these like the converted date () and
are SELECT, INSERT, UPDATE, some other functions which are
DELETE, CREATE, and DROP. not part of the regular SQL.
Chapter 3: PL/ SQL Block: STRUCTURE,
Syntax, ANONYMOUS Example
Block Structure
This is the first section of the PL/SQL blocks. This section is an optional part.
This is the section in which the declaration of variables, cursors, exceptions,
subprograms, pragma instructions and collections that are needed in the
block will be declared. Below are few more characteristics of this part.
Execution part is the main and mandatory part which actually executes the
code that is written inside it. Since the PL/SQL expects the executable
statements from this block this cannot be an empty block, i.e., it should have
at least one valid executable code line in it. Below are few more
characteristics of this part.
Exception-Handling Section:
BEGIN --mandatory
<executable statements. At least one executable statement is
mandatory>
EXCEPTION --optional
<exception handles>
END; --mandatory
/
Anonymous blocks:
Anonymous blocks are PL/SQL blocks which do not have any names
assigned to them. They need to be created and used in the same session
because they will not be stored in the server as database objects.
Since they need not store in the database, they need no compilation
steps. They are written and executed directly, and compilation and
execution happen in a single process.
Named blocks:
Named blocks have a specific and unique name for them. They are stored
as the database objects in the server. Since they are available as database
objects, they can be referred to or used as long as it is present on the server.
The compilation process for named blocks happens separately while
creating them as a database objects.
Summary
After this tutorial, you should be aware of PL/SQL blocks and its types,
different sections of blocks and their usages. The detailed description of the
named PL/SQL blocks will be covered in the later tutorial.