First, the basic usage
- PL / SQL process data display (output)
set serveroutput on; - a display output
set serveroutput on; - Close output
dbms_output.put_line (); - Client output - Assignment of variables and constants
keyword default;
assignment statement: =;
using statement SELECT ····· INTO ·······
variable Connectors: ||;
accepting user input: variable name: = '& variables name'; - Properties Type
% TYPE: reference variable and the data type of a database column;
% ROWTYPE: providing record type represented by row in a table;
use attribute type advantages: does not need to know the specific type of the referenced table columns.
Second, the control structure
- Conditions control
-IF statement
-CASE statement
- Circulation control
-LOOP loop
-WHILE cycle
-FOR cycle
- Sequence control
-GOTO statement
-NULL statement
Third, dynamic SQL
-
Execute dynamic SQL syntax
example:
-
Dynamic SQL statements executed with parameters
Example:
Fourth, exception handling
-
Exception type
a, the predefined exception - Implicit initiated when the PL / SQL program violates Oracle rule or exceed the system limit;
B, a user-defined exception - the user may define an exception in PL / declaration section SQL blocks, custom exception by RAISE statement to explicitly throw. -
Predefined exception handling
-
Custom exception handling
-
Non-predefined exceptions