One: Plsql Overview: Plsql is a process language that Oracle expands on the basis of SQL. Plsql provides typical high-level language features, including encapsulation, exception handling mechanisms, information hiding, object-oriented, etc., and brings new programming ideas to the database server and toolset. Compared with java, C #, the Plsql advantage is that the SQL language can be written directly into Plsql's "blocks" or plsql processes and functions. There is no need to create a statement object to execute sql; like Java, which makes Plsql a very powerful transactional language, which is to use SQL to process data and handle business logic using a control structure. Two: Plsql block concept: Plsql is a kind of Pascal language, each program is composed of block declare (Optional) Variables, cursors, user-defined Exceptionsbegin (Mandatory) ? SQL statements PL statementsexception (Optional) Actions to perform when errors occurend; (M Andatory) Three: Plsql variable type: 1, the system built-in general simple variable type 2, user-defined complex variable type: For example, record type 3, reference type: Save a pointer 4, large object type (LOB): Save a point to the large object of the address Four: Common function Introduction: Dbms_output. Put_Line (); output, output the value of the intermediate variable when debugging select into statement: Used to store the contents of the query from the database into variables insert, UPDATE, DELETE, Merge statement: Executing these SQL statements in Plsql is similar to executing these statements directly, except that you can use PLSQL declared variables in SQL statements; Five: Plsql control statements: ①: Conditional Statements If Conditionthen statements; [elsif conditionthen statements;] [ELSE statements;] END if; case selectorwhen expression1then result1when ExprEssion2then result2 ... When Expressionnthen Resultn[else resultn+1;] END Case; ②: Loop statement loop statement1;. . . EXIT [when condition]; END loop; whileconditionloopstatement1;statement2; . . . END loop; for counter in [Reverse]lower_bound.. upper_boundloop statement1; Statement2; . . . END LOOP;
Plsql syntax in layman's language