Frequently used:
Value assignment: [: =]
Connection character: [|]
Output: dbms_out.put_line ('some text ');
1. The example of the output of the application variable assignment is as follows:
Declare
X varchar2 (10); -- declare a variable
Begin
X: = 'this is '; -- Colon equal sign assignment: =
Dbms_output.put_line (the value of 'x is '| x); -- double vertical bars | different data types can be connected and Output
End; -- pay attention to the semicolon
/
2. Run the set HELP Command [? Set]
3. set serveroutput on size 10000 to set the cache. The maximum value is 1000000.
4. Line comment :--
5. Block comments /**/
6. Case 2: Exercise connection Variables
Declare
X varchar2 (10): = 'this is ';
Y string (10): = 'value of y ';
Z varchar2 (20 );
Begin
Z: = x | y; -- connect two variables
Dbms_output.put_line (z); -- output
End;
/
7. Case 3 [if endif], with if judgment added.
DECLARE
A number;
B varchar2 (10 );
Begin
A: = 2;
If a = 1 then
B: = 'a ';
Elsif a = 2 then -- Here elsif is not elseif
B: = 'B ';
Else
B: = 'C ';
End if; -- endif do not forget
Dbms_output.put_line ('B's value is' | B );
End; -- the semicolon after end is also crucial. Do not forget
/
8. CASE 4 [case endcase] usage
Declare
A varchar2 (10 );
B number;
Begin
A: = 'a ';
Case -- start with case
When a = 'A' then B: = 1; -- embedded with many when then statements
When a = 'B' then B: = 2;
When a = 'C' then B: = 3;
Else
B: = 'others ';
End case; -- end of case with a semicolon
Dbms_output.put_line ('B's value is' | B );
End;
/