One: PL/SQL program block
PL/SQL is a block-structured language, and a PL/SQL program is a code logic block.
The PL/SQL program consists of three components:
| 1 |
Declarations Section Starting with the keyword DECLARE , it is an optional part that declares all variables, cursors, subroutines, and other elements that are used in the program with the assigned initial value . |
| 2 |
Executable Commands Section Use the keyword begin and end packages , must have. Defines a series of PL/SQL statements . |
| 3 |
Exception Handling Section Use the keyword EXCEPTION, Optional, to handle exceptions captured by the executable commands section . |
Two: Basic format
DECLARE <declarations section>BEGIN <executable command (s) >EXCEPTION <exception Handling>END;
Three: Notes
Single-line comment: Use separators--。
Multiline Comments:/* and */.
Four: operational symbols
| +, -, *, / |
addition, subtraction/negation, multiplication, division |
| % |
Property Index |
| ‘ |
String |
| . |
Dot operator |
| (,) |
An expression or list separator |
| : |
Host variable Indicator |
| , |
Item Separator |
| " |
Quoted identifier delimiter |
| = |
Relational operators |
| @ |
Remote Access Indicator |
| ; |
Declaration Terminator, Statement Terminator |
| := |
Assignment operators |
| = |
Operator Association |
| || |
Connection operators, string connections |
| ** |
Exponentiation operator |
| <<, >> |
Label delimiter (start and end) |
| /*, */ |
Multiline comment delimiter (start and end) |
| -- |
Single-line Comment indicator |
| .. |
Range operations |
| <, <=, >= |
Relational operators |
| <>, ' =, ~=, ^= |
Unequal operators |
Five: Program unit
PL/SQL Program unit: A named PL/SQL block in a database that is stored as a database object in a database.
There are five main categories:
PL/SQL Block: A block of program code that carries out some action, including the three blocks mentioned above (where declarations, exceptions are optional).
Procedure: Performs a specific operation with no return value.
Function: A complex calculation with a return value.
Package: Logically related procedures and functions are organized together, analogous to classes in Java.
Trigger: Event trigger, perform the appropriate action.
Basic block format and syntax for PL/SQL Learning notes