PLSQL Introduction

Oracle 6.0 Introduced PLSQL

PLSQL is an procedural language extension for SQL, PLSQL is an block structure programming language, When we are submitting PLSQL block into the oracle server all SQL statements are executed within SQL engine and also all procedural statements are executed within PLSQL engine, It is the combination of procedural, DML.

Syntax of Block Structures

DECLARE (optional)

Variable declaration

Cursor,

User defined exceptions;

BEGIN (mandatory)

Select into clause;

DML, TCL statements;

Conditional statements;

Control statements;

EXCEPTION (Optional)

Handling runtime errors;

END; (Mandatory)

There are to types of blocks supported by PLSQL

  1. Anonymous Block (or) Unnamed Block
  2. Named Block
  • Anonymous Block:

These blocks does not have a name and also not stored in database, we cannot call these blocks in another block or in client applications.

Syntax of Anonymous Block:

DECLARE

Declare_variable datatype;

BEGIN

Call_procedure(parameters);

END;

  • Named Blocks

These Blocks having a name and also automatically stored in database, these blocks used by all types of programmers in all applications, these are procedures, functions, triggers, packages etc.