First, the data type in PL / SQL, just as follows:
Number [(M, N)] Unique numerical type. M-precision, N-decimal number. Integer, REAL is defined by the synonym of Number.
VARCHAR2 (MAXSIZE [CHAR | BYTE]) Unique string type. Char, Vachar is defined by the synonym of VARCHAR2. NVARCHAR2 is the same as VARCHAR2 performance, just for international character set data types.
Date Date / Time Type.
Boolean Boolean. Only True, False two values.
Second, PL / SQL active body
Declare
- Variable declaration
Begin
- Run statement
EXCEPTION
- Abnormal treatment
END;
Third, PL / SQL control structure
1, if-kilsif structure
IF condition THEN
Elsif Conditions THEN
END IF;
2, CASE structure
Case
When Condition THEN
When Condition THEN
...
Else All conditions are not met
END;
Fourth, loop structure (see example)
DeClarei Integer; Begin
DBMS_OUTPUT.PUT_LINE ('loop output'); i: = 0; LoopeXit When I> = 10; dbms_output.put_line (i); i: = i 1; end loop; dbms_output.put_line ('while output'); i : = 0; While i <10 loopdbms_output.put_line (i); i: = i 1; end loop; dbms_output.put_line ('for output'); for i in 1..10 loopdbms_output.put_line (i); endput LOOP;
Exception when others the dbms_output.put_line ('Exception'); Raise; End; /