Inf 3
Inf 3
CREATING PROCEDURES
Procedures makes the program modular and each module performs a specific function or task.
Modular programming approach makes the program readable,manageable,reusable and reliable.
A Module or Procedure is a logical unit of work ie,a logically grouped set of SQL and PL/SQL
statements that together perform a specific task.
2. Stored Procedure: These are named procedures.These can accept input parameters and pass
values to output parameters.
Need of Procedures:
1. Procedures makes a program modular and serve to meet the specific requirement.
2. They make a bigger program broken down into smaller and manageable units.
3. They enhance performance of a program by saving time in network traffic as they do not need
recompilation as their compiled form is stored in the database.
4. They enhance reusability as a procedure once written can be used again or reused.
HEADER
IS
DECLARATION SECTION
BEGIN
END;
The declaration and exception sections are optional in any PL/SQL block.
The PROCEDURE body begins with the keyword IS or AS and ends with the keyword
END followed by an optional procedure name. The procedure body has three parts:a
declarative part,an executable part,and an optional exception-handling part.
PARAMETER MODES:
3. Data type.
NOTE: Numerically constrained types such as NUMBER(2) or VARCHAR(20) are not allowed in a
parameter list.
SYNTAX:
CREATE FUNCTION <func_name>(list of parameters)RETURN <return type>
AS….
BEGIN
--function body
END ;
NOTE: A function like a procedure receives arguments from the calling program.The difference is that a
function is a part of an expression and returns a single value to the calling program for its use.
***