What is "pl-sql"

PL/SQL (acronym for Procedural Language/Structured Query Language) is an extension of the standard SQL language for Oracle DBMS. It is an Oracle procedural language that extends the SQL language.

PL/SQL is a programming language based on monographic editing options. It consists of three layers, definition, editing, and completion.

Basic Structure of PL/SQL

With PL/SQL, you can use SQL statements to manipulate Oracle data and flow control to process the data. In addition, you can declare constants and variables, define procedures and functions. Thus, PL/SQL combines the manipulation power of SQL data with the data processing power of procedural languages.

The basic units (procedures, functions and anonymous blocks) that make up a PL/SQL program are logical blocks, which can contain any number of nested subblocks. Typically, each logical block corresponds to a problem or subproblem to be solved. Thus, PL/SQL supports the "split-to-conquer approach" for troubleshooting called step-by-step refinement.

A block (or subblock) allows grouping logically related statements. This way, you can put statements near where they are used. Declarations are local to the block and cease to exist when the block is completed.

The basic unit in PL/SQL is a block. All programs in PL/SQL are composed of blocks, which can be located inside each other. Usually, each block performs a logical action in the program. A block has basically the following structure:

DECLARE

Section for declaration of variables, local types and subprograms.

BEGIN

Executable section, in this section are the procedural and SQL statements. This is the only section of the block that is indispensable and mandatory.

EXCEPTION

Section/Sector where the exception instructions are. Ex: empty value, duplicate value

END

The order of the parts follows a logic. First comes the declarative part, in which objects can be declared. Once declared, objects can be manipulated in the executable part. Exceptions that arise during execution can be dealt with in the exception treatment part.

You can nest subblocks in the executable part and in the exception handling part of a PL/SQL block or subprogram, but not in the declarative part. In addition, you can define local subprograms in the declarative part of any block. However, you can call local subprograms only from the block in which they are defined.


More Information