PL Oracle Database / SQL using the (four)

First, the basic usage

  1. PL / SQL process data display (output)
    set serveroutput on; - a display output
    set serveroutput on; - Close output
    dbms_output.put_line (); - Client output
  2. Assignment of variables and constants
    keyword default;
    assignment statement: =;
    using statement SELECT ····· INTO ·······
    variable Connectors: ||;
    accepting user input: variable name: = '& variables name';
  3. Properties Type
    % TYPE: reference variable and the data type of a database column;
    % ROWTYPE: providing record type represented by row in a table;
    use attribute type advantages: does not need to know the specific type of the referenced table columns.

Second, the control structure

  1. Conditions control
    -IF statement
    Here Insert Picture Description
    -CASE statement
    Here Insert Picture Description
  2. Circulation control
    -LOOP loop
    Here Insert Picture Description
    -WHILE cycle
    Here Insert Picture Description
    -FOR cycle
    Here Insert Picture Description
  3. Sequence control
    -GOTO statement
    Here Insert Picture Description
    -NULL statement

Third, dynamic SQL

  1. Execute dynamic SQL syntax
    Here Insert Picture Description
    example:
    Here Insert Picture Description

  2. Dynamic SQL statements executed with parameters
    Here Insert Picture Description
    Example:
    Here Insert Picture Description

Fourth, exception handling

  1. Exception type
    a, the predefined exception - Implicit initiated when the PL / SQL program violates Oracle rule or exceed the system limit;
    B, a user-defined exception - the user may define an exception in PL / declaration section SQL blocks, custom exception by RAISE statement to explicitly throw.

  2. Predefined exception handling
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description

  3. Custom exception handling
    Here Insert Picture Description
    Here Insert Picture Description

  4. Non-predefined exceptions
    Here Insert Picture Description

Published 36 original articles · won praise 7 · views 2063

Guess you like

Origin blog.csdn.net/q_2540638774/article/details/103825816