 . It contains the instructions of the program. If a variable is used in this section when it has not been declared in the declaration section, the compiler will generate an error. Finally, the last section is called if there is an error in the previous section. It begins with the EXCEPTION statement and treats all the exceptions raised in the main section.
Structure of the code
PL / SQL allows you to group the instructions in procedures and functions , these terms have the same meaning as in Pascal : A function is a block of code taking settings and performs processing for a returned result, a procedure covers The same concept except that a procedure does not return a result. The arguments passed to procedures and functions can be given read-only ( IN ), write ( OUT ) or read-write ( IN OUT ) The developer can also choose the passage by value (normal behavior) or by reference ( NO COPY ).
Functions and procedures can be grouped together in units named packages , which are then accessible under the same namespace. In a manner similar to Pascal’s modules, creating a package requires writing a specification outlining the prototype of the package’s functions and procedures, as well as public variables and types . Secondly, the implementation of the package is done separately; It contains the code of procedures and functions as well as the declaration of private elements.
Version 8i introduced the concept of object and implementations from 9i support the object-oriented programming including the legacy . A PL / SQL class is described as a type. It has a structure similar to that of a PL / SQL package: first the declaration of the methods, then their implementation in the body .
The first types of variables available are SQL types supported by the Oracle server ( INTEGER , VARCHAR , …), but it is possible to define custom types.
Notes and references
- ↑ http://www.dbspecialists.com/files/presentations/native_plsql.html [ archive ]
- ↑ http://www.scribd.com/doc/16654335/Plsql-New-in-11gr1 [ archive ]
- ↑ http://swervedba.wordpress.com/2011/07/ [ archive ]