Sitemap

Pl SQL Block Structure

2 min readJan 2, 2020

--

pl sql block structure

Overview to PL/SQl

  • PL/SQL is a Procedural Language extension of non­ procedural Structured Query Language (SQL). PL/SQL is specially mainly designed for Database oriented activities.
  • It combines the data manipulation power of SQL and procedural power of standard programming languages.
  • PL/SQL is the superset of of SQL. So, it fully supports SQL data manipulation commands and SQL data types.
  • PL/SQL also has boolean and composite data types to handle complex data.
  • PL/SQL is not a case sensitive language. It supports standard programming features such as control statements, procedures and functions. learn more through pl sql online training

PL/SQL Block Structure

  • PL/SQL is block structured language divided into three logical blocks.
  • BEGIN block and END; keyword are compulsory, and other two block DECLARE and EXCEPTION are optional block.
  • END; is not a block only keyword to end of PL/SQL program.
  • PL/SQL block structure follows divide­ and ­conquer approach to solve the problem stepwise. prepare on pl sql interview questions

Basic Syntax structure

Declare

Declaration of variable, constants

Begin

Execute statements in plsql

Get Veeereshkumar’s stories in your inbox

Join Medium for free to get updates from this writer.

Exception

Exception handlers in pl sql

END;

DECLARE:

Variables and constants are declared, initialized within this section.

Variables and Constants:

In this block, declare and initialize variables (and constants). You must have to declare variables and constants in declarative block before referencing them in procedural statement.

Declare Variables and Assigning values:

Define variable name, data type of a variable and its size. Date type can be: CHAR, VARCHAR2, DATE, NUMBER, INT or any other.

Declare Constants and Assigning values:

Constants are declared same as variable but you have to add the CONSTANT keyword before defining data type. Once you define a constant value you can’t change the value.

BEGIN/Executable Section

It starts with the keyword BEGIN and ends with END. this is the section where the program logic is written to perform any task. The programmatic constructs like loops, conditional statements and SQL statements form the part of Executable section.

EXCEPTION

Exception section of a PL/SQL block starts with the keyword EXCEPTION. Any errors in the program can be handled in this section, so that the PL/SQL block terminates gracefully.

To get expert level training on pl sql. master your skills through sql online training

Gökhan YAVAŞ Muhammed Hilmi Koca Alex José Silva NERMİN PARLAK

--

--

Veeereshkumar
Veeereshkumar

Written by Veeereshkumar

I am technical writer and provides various blogs on various technologies from scracth