PL/SQL PROCEDURE

A Procedure is simply a block which performs one or more specific tasks. 

A procedure contains a header and a body:

  • Header: The header contains name of the procedure and the variables passed to the procedure.
  • Body: The body contains a declaration section, execution section and exception section.
We can pass the parameters in the procedure in three ways:
  • IN parameter: It can be referenced by procedure or function. The value of the parameters can't be overwritten by the procedure or the function.
  • OUT parameter: It can't be referenced by procedure or function. The values of the parameters can be overwritten by the procedure or the function.
  • INOUT parameter: It can referenced by the procedure or function. The values of the parameters can be overwritten by the procedure or function.
Syntax:

CREATE Procedure_name
    [parameters]
IS
    [declaration section]
BEGIN
    [executable section]
[EXCEPTION
    Exception_section]
END[procedure_name]

Example:

create procedure "INSERTUSER"(
id IN NUMBER,
name IN VARCHAR2)
is
begin
insert into values(id, name);
end;

PL/SQL program to call procedure:

BEGIN
    insertuser(101, 'AKSHAY');
    dbms_output.pu_line('record inserted succesfully');
END;

Syntax to DROP Procedure:
DROP PROCEDURE procedure_name


Source: javatpoint

Comments

Popular posts from this blog

THREE LEVELS OF DATA INDEPENDENCE

Python-HackerRank Problem List Comprehensions

Python Problem Solving - Lonely Integer