October 11, 2021

CurledMark

curled up on the sofa

A block is a unit of code that provides execution and scoping boundaries for variable declarations and exception handling. PL/SQL allows you to create anonymous blocks (blocks of code that have no name) and named blocks, which may be packages, procedures, functions, triggers, or object types.

Pl/sql over SQL

SQL is a powerful tool, but it has some disadvantages, such as, execute only one query at a time and no error handling mechanism.

To prevent these disadvantages oracle provided Pl/SQL.

What is pl/sql?

Procedural Language/ Structured query language is a Procedural language that brings programming language features to SQL.

Introduction to PL/SQL Anonymous Block

Features

• Tool to Validate, control, manipulate and restrict unauthorized access of data from SQL database.
• Improves the application performance.
• Deals with errors by using exception handling.

Advantages

1. Procedural language capability
2. Better performance
3. Error handling
4. Application portability

Architecture

Programs are organized into blocks. Each block consists of three logical sub blocks. They are:

Declaration(optional)
Execution(mandatory)
Exception handling(optional)

Block structure

DECLARE
//Declare section
— Declaration of cursors, variables, records, constants
BEGIN
//Execution section
— Executable statements/ instructions
EXCEPTION
//Exception handling
— Error handling
END;

Example

DECLARE
Num1 number[5] :=2;
Num2 number[5] :=4;
result number [5];
BEGIN
result:= Num1+Num2;
dbms_out.put_line(‘The sum of Num1 and Num2 :=’।। result);
END;
/

Also read:

THE BIOGRAPHY OF SWAMI VIVEKANANDA

THE SHAWSHANK REDEMPTION EXPLAINED

Turtles All the Way Down by John Green Story Explained

Essentialism The Disciplined Pursuit of Less by Greg McKeown Summary

The One from the Stars by Keshav Aneel

The Miracle Morning Guaranteed to Transform Your Life (Before 8 AM)

The Little Prince Book Summary by Antoine de Saint-Exupery

The Courage to Be Disliked Book Summary

Who Will Cry When You Die By Robin Sharma Summary

Steal Like an Artist by Austin kleon Summary

Looking for Alaska Book by John Green | Summary

The Kite Runner By Khaled Hosseini Summary

When Breath becomes Air by Paul kalanithi Summary

IKIGAI THE JAPANESE SECRET TO A LONG AND HAPPY LIFE SUMMARY

The Rudest Book Ever by Shwetabh Gangwar | Summary

Good Will Hunting Story Explained