1. PL/SQL is a block structure language. It stores a group of statements in a block and sends them to the server at one time. The statements are compiled and then executed. For PL/SQL blocks with names, they can be compiled separately and permanently stored in the database and ready for execution at any time. Advantages of PL/SQL:
A. supports SQL (Case Insensitive ). b. supports object-oriented processes. c. better performance (SQL is a non-procedural language and can only be executed one by one. PL/SQL can compile one block at a time ). d. portability. e. security. 2.pl/ SQL block Syntax:
[DECLARE--decalration statements] BEGIN--executable statements [Exception--exception statements]End;
3. assignment operator :(: =, default, select .. into), special symbol: (|, --, ** power operation, for example, 3 ** 2 = 9), relational OPERATOR: (>,<,>=, <=, =, <> ,! =), Logical operators (and, or, not ). 4. Conditional Control statement:
If condition 1 then Condition 1 struct elsif condition 2 then condition 2 struct end if; and Case: case [selector] When expression 1 then Statement 1; when expression 2 then Statement 2; elseend case; the options must match the values; otherwise, an error is returned. Example of using case as an expression: p_grade: = casewhen v_grade = 'A' then'a' else 'bb' end;
5. loop Structure: unconditional loop (loop-end loop statement): loop -- loop body end loop; while loop statement: whlie condition loop body end loop; For Loop statement: for Loop Variable in [reverse] loop upper limit .. the lower limit of loop the end loop of the loop body. For example:
declare counter number(3):=0; sumResult number:=0;begin dbms_output.put_line(counter); for counter in 1..100 loop dbms_output.put_line(counter); sumResult:=sumResult+counter; end loop; dbms_output.put_line('result is :'||sumResult);end;