- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Block of PL/SQL in Oracle DBMS
PL/SQL is a block structured language i.e the code of PL./SQL is written in the form of blocks. PL/SQL also contains the robustness, security and portability of the Oracle database.
Each block of PL/SQL contains the following subparts −
- Declarations - This section contains all the items that needs to be declared before the program such as variables, subprograms etc. This section contains the keyword DECLARE at its start. In general, Declarations is an optional subpart of the PL/SQL program.
- Executable Commands - This section of the PL/SQL code contains the executable statements. It contains BEGIN and END at its starting and ending. Executable commands is a compulsory section and it cannot be left blank. In case there are no executable statements, NULL is written to signify this.
- Exception Handling - This section contains the code to handle all the errors or exceptions that may arise during the course of the program.Exception handling section starts with the keyword EXCEPTION.
Structure of a PL/SQL Block
The basic structure of a PL/SQL block is
DECLARE < Declarations section > BEGIN < Executable commands section > EXCEPTION < Exception handling section > END;
An example of a PL/SQL code is −
SET SERVEROUTPUT ON BEGIN DBMS_OUTPUT. PUT_LINE FOR j IN 1..10 LOOP DBMS_OUTPUT.PUT_LINE(‘Number”|| j ); END LOOP; END;
This program displays the first ten natural numbers in order.
- How to capture Oracle errors in PL/SQL?
- Explain the PL/SQL Engine in DBMS
- Database Wars: MSSQL Server, Oracle PL/SQL and MySQL
- Difference between SQL and PL/SQL
- What is PL/SQL?
- Print pyramid of tutorialspoint in PL/SQL
- Difference Between T-SQL and PL-SQL
- Cursors in Oracle DBMS
- Functions in Oracle DBMS
- Reverse a Number in PL/SQL
- Program for Fibonacci numbers in PL/SQL
- Floyd's triangle in PL/SQL
- Finding sum of first n natural numbers in PL/SQL
- Difference between Oracle and SQL Server
- Find the factorial of a number in pl/sql using C++.