About PL/SQL content, mainly includes anonymous blocks , stored Procedures , and storage functions Three forms of PL/SQL blocks, and how variables , types , Flow control Statements , cursors , triggers , exceptions , and how to use PL/SQL blocks to access data in a database .
PL/SQL Overview
If SQL is a standard database-access language, PL/C is a programming language developed by Oracle, which is an extension of SQL.
In a PL/SQL program, you can define variables , data types , functions , and procedures , you can use flow control statements , you can include SQL statements , and you can for error handling .
With the PL/SQL program, complex access to the database is possible.
PL/SQL has a number of advantages , such as the idea of Modular program design, which can be defined in the PL/SQL program to accomplish different functions.
PL/SQL applications can also be easily ported between different platforms and different computers.
In addition, the use of PL/SQL programs can greatly improve the efficiency of accessing the database , because the PL/SQL program can be executed in sql*plus , or it can be invoked in the client's application , as long as it knows
The name of the PL/SQL program, you can call it.
A comparison of PL/SQL programs with traditional execution methods
Traditional SQL commands are executed separately, and each time a client executes an SQL statement, it makes a request to the database server and returns a result from the server.
The PL/SQL program is executed as a whole, and the client only needs to make one request, and the server only returns one result after execution.
PL/SQL is a structured programming language in which the basic unit of a program is a block, with functions, procedures, and anonymous blocks in the main block form .
A PL/SQL block consists of the following three parts:
DECLARE
Declarations section
BEGIN
Executable section
EXCEPTION
Exception Handling Section
END
Where the Variable declaration section is used to define variables, types, cursors, subroutines, triggers, exceptions, and so on.
Declared elements are valid within the scope of this block.
This section is optional in the PL/SQL block.
The executable part is the body of the PL/SQL block, which contains the executable code of the PL/SQL block, which is an essential part.
The functionality of PL/SQL blocks is mainly reflected in this section.
The exception handling section is used to handle errors that occur during the execution of a PL/SQL block.
If the block performs normally, the block ends normally, or the exception is handled by starting with the statement where the error occurred and going to the exception handling section to begin execution .
This section is also optional in the PL/SQL block.
the simplest PL/SQL block contains only the executable parts that are bounded by begin and end .
For example:
BEGIN
Dbms_output. Put_Line (' Hello,world ');
END;
PL/SQL Programming _ Overview