Basic What is PL / SQL? PROCEDURAL LANGUAGE STRUCTURED Query Language is a programming environment that is directly residing in the database directly in the database.
Below is the aspects that should be noted in PL / SQL programming:
1. The variable value is used to use the ": =" symbol.
Universal format: variable_name variable_type: = value; for example: I number: = 0;
Common data type: varchar2, number, date, boolean.
2, control structural IF logic structure 1, IF condition THEN statement; endiff;
For example: if l_date> '12 -APR-03 'THEN statement; END IF
Note: Unlike many other programming languages, if the IF is not directly incorporated, it can be used: if not (l_date <= '12-apr-03') THEN statement;
Equivalent to the above statement
Second, IF condition THEN statement; ELSE statement; endiff;
Third, IF condition THEN statement; ELSIF condition THEN statement; END IF;
Circulating structure 1, while cycle
WHILE condition loop statement; end loop; two, for loop (very special) for l_counter in 1..5 - loop 5 times, the value of the variable L_Counter has been incremented from 1 to 5. (add Reverse after IN, you can decrement count) ) Loop statement; end loop;
one example:
Using the serveroutput and dbms_output function First open the output tool: SET ServerOutput On Size 100000 Enter the following: SQL> DECLARE 2 L Number; 3 Begin 4 for l in reverse 1..5 5 loop 6 dbms_output.put_line (l); End loop; 8 end; /
You can see the results of the run.