Procedures
Procedures
abhirami t
• A subprogram is a program unit/module that performs a
particular task.
• 1 Declarative Part
• 2 Executable Part
• 3 Exception-handling
PROCEDURE
• Procedure is a named PL/SQL block that performs one or more
specific tasks.
• It is a stored subprogram that can be called explicitly by other
programs or procedures.
• Procedures in PL/SQL help in modularizing and organizing
code, promoting code reusability, and enhancing
maintainability.
• A procedure is created with the CREATE OR REPLACE
PROCEDURE statement.
CREATE [OR REPLACE] PROCEDURE procedure_name
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
{IS | AS}
BEGIN
< procedure_body >
END procedure_name;
• Procedure-name specifies the name of the procedure.
• The optional parameter list contains name, mode and types of the parameters.
IN represents the value that will be passed from outside and OUT represents the
parameter that will be used to return a value outside of the procedure.An INOUT
parameter passes an initial value to a subprogram and returns an updated value
to the caller
Procedure created.
A standalone procedure can be called in two ways −
• Using the EXECUTE keyword
• Calling the name of the procedure from a PL/SQL block
The above procedure named 'greetings' can be called with the EXECUTE
keyword as −
EXECUTE greetings;
The above call will display −
Hello World
PL/SQL procedure successfully complete
The procedure can also be called from another PL/SQL block −
BEGIN
greetings;
END;
/
The above call will display −
Hello World
• Positional notation
• Named notation
• Mixed notation
In positional notation, you can call the procedure as −
• findMin(a, b, c, d);