02.basic SQL Procedure Structure
02.basic SQL Procedure Structure
Unit Objectives
After completing this unit, you should be
able to:
Describe the structure of an SQL procedure
Explain various clauses of the CREATE
PROCEDURE statement
List the statements that can be coded in the
procedure body
Alter Procedure
Drop Procedure
Create Module
Replace Module
Alter Module
Drop Module
Where to Use ;
Declarations
Local variables
DECLARE var_name datatype[ DEFAULT
value];
Declarations
Condition declaration:
DECLARE not_found CONDITION FOR
SQLSTATE 02000;
Handler declaration:
DECLARE EXIT HANDLER FOR
SQLEXECPTION;
Assignments
Modules: Overview
Module = bundle of several related
objects:
SPs, UDFs, global variables and cursors,
types, conditions
Similar to a class in OO languages (but single
instance)
Information hiding
Each object can be public or private
Modules: Module
Implementation
Unit Summary
Having completed this unit, you should be able
to:
Describe the structure of an SQL procedure
Explain various clauses of the CREATE
PROCEDURE statement
List the statements that can be coded in the
procedure body
Alter Procedure
Drop Procedure
Create Module
Replace Module
Alter Module
Drop Module