SlideShare a Scribd company logo
1Using ORACLE®Procedures and Functions
2ProceduresA procedure is a collection  of  SQL and procedural statements that perform a specific task and are assigned a unique name within the schema and stored in the  database.Advantages of Procedures:Dividing the program into smaller manageable unitsStored in compiled form , hence improve performance.Enable creation of reusable code.DBA can grant/revoke privileges to users to access procedures, hence better security.Reduce network traffic as they are stored in the database .
3Types of Procedures There are two kinds of procedures:Anonymous: These procedures do not have a name assigned to them. It is complied each time when the user submits its source code to the database server. Stored : Unlike anonymous, stored procedures have a unique name assigned to them and are stored in the compiled form in the database.	   NOTE: Only Stored procedures can accept parameters and does not use the 				DECLARE BLOCK.
4Procedure SyntaxSYNTAX:CREATE [/REPLACE] PROCEDURE procedure_name [(parameter datatype),…...][LANGUAGE { ADA|C|….|SQL}ASStatement 1;…..……			    Procedure body.	SQL/PLSQL statements….….END;To execute the procedure:EXEC procedure_name;
5Procedure ExampleCREATE OR REPLACE PROCEDURE InfoTable_procAScounter number;c_name varchar2(15);BEGINDBMS_OUTPUT.PUT_LINE('in order');counter :=10;loopselect name into c_name FROM ConTable where ID=counter;DBMS_OUTPUT.PUT_LINE(c);EXIT WHEN counter<1;END LOOP;end;
6FunctionA function is a stored sub-routine that returns one value and as only input parameters.A stored function is same as a procedure except for the procedure keyword is replaced by the keyword function and it carries out a specific operation and returns a value.As functions do not take output parameters it must be assigned to a variable in the program.SYNTAX:CREATE OR REPLACE FUNTION function_name (<parameter list>)RETURN <return_type>ASvariable declarations if any……BEGINStatement1……END
7Function Example CREATE OR REPLACE FUNCTION f1( n IN NUMBER)RETURN NUMBERAS	c NUMBER(4);			Variable declarationf NUMBER(4);BEGIN	c:=1;	f:=1;WHILE (c<=n)	LOOP				  Function Bodyf:=f*c;		c:=c+1;	END LOOP;RETURN f;END;	    This function when executed calculates the factorial of the parameter n.
8ParametersBoth PROCEDURE or FUNCTION take different parameters. There are three different types of parameters :
THANK YOU9THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit:  www.dataminingtools.net

More Related Content

PPTX
Oracle: PLSQL Introduction
PPT
10g plsql slide
PPTX
Packages in PL/SQL
PPTX
4. plsql
PDF
Packages - PL/SQL
PDF
Programming in Oracle with PL/SQL
PDF
PPTX
pl/sql Procedure
Oracle: PLSQL Introduction
10g plsql slide
Packages in PL/SQL
4. plsql
Packages - PL/SQL
Programming in Oracle with PL/SQL
pl/sql Procedure

What's hot (17)

PPTX
PLSQL Tutorial
PPTX
Procedure and Functions in pl/sql
PPTX
PL/SQL Fundamentals I
PPTX
ORACLE PL SQL FOR BEGINNERS
PPTX
Cursors, triggers, procedures
PDF
Pl sql-ch2
PPT
PL/SQL Introduction and Concepts
PPTX
Oracle: DDL
PPTX
ORACLE PL/SQL
PPT
1 - Introduction to PL/SQL
RTF
Trigger and cursor program using sql
PDF
Oracle sql & plsql
PPT
PPT
Oracle PLSQL Step By Step Guide
PPT
Basic cursors in oracle
PPT
PLSQL Cursors
PPTX
Oracle: Cursors
PLSQL Tutorial
Procedure and Functions in pl/sql
PL/SQL Fundamentals I
ORACLE PL SQL FOR BEGINNERS
Cursors, triggers, procedures
Pl sql-ch2
PL/SQL Introduction and Concepts
Oracle: DDL
ORACLE PL/SQL
1 - Introduction to PL/SQL
Trigger and cursor program using sql
Oracle sql & plsql
Oracle PLSQL Step By Step Guide
Basic cursors in oracle
PLSQL Cursors
Oracle: Cursors
Ad

Viewers also liked (16)

PDF
Transportation Marketplace
ODP
España
PDF
PPTX
사이버컴과 네트워크분석 9주차 2
PDF
San francisco
PPTX
Zahid latif khan securities (pvt) ltd
PPTX
최종과제 윤아영지혜린
PPTX
Khumbi ke kasht Key Marahial A Presentation By Mr Allah Dad khan Former Dir...
PPTX
Guía de aprendizaje 2: certificados y comunidad
PDF
Heather growth marketing conf 2016
PPTX
사이버컴과 네트워크분석 7주차 1
PDF
OpenBar for social sales collaboration - Massimo Barboni
PPTX
Vincent gmc growth hacking ultimate version october 2016
PPT
Innovation Strategy
PDF
استاذ
DOCX
Informationsecurity
Transportation Marketplace
España
사이버컴과 네트워크분석 9주차 2
San francisco
Zahid latif khan securities (pvt) ltd
최종과제 윤아영지혜린
Khumbi ke kasht Key Marahial A Presentation By Mr Allah Dad khan Former Dir...
Guía de aprendizaje 2: certificados y comunidad
Heather growth marketing conf 2016
사이버컴과 네트워크분석 7주차 1
OpenBar for social sales collaboration - Massimo Barboni
Vincent gmc growth hacking ultimate version october 2016
Innovation Strategy
استاذ
Informationsecurity
Ad

Similar to Oracle: Procedures (20)

PPT
05 Creating Stored Procedures
PDF
SQL Procedures & Functions
TXT
Sql procedures
PPTX
Procedure n functions
PPS
Procedures/functions of rdbms
PPTX
5. stored procedure and functions
PPT
plsql les01
PDF
Lecture Notes Unit5 chapter17 Stored procedures and functions
PPT
Module04
PPTX
Relational Database Management System
PPTX
Sql Functions And Procedures
PPTX
MS SQL SERVER: Sql Functions And Procedures
PPTX
MS SQLSERVER:Sql Functions And Procedures
PPTX
Lecture 3.2_Subprogrammm - Function.pptx
PPTX
Unit 3
PPTX
Stored procedures
PPTX
Pl/SQL Procedure,Function & Packages - sub programs
PPTX
9. DBMS Experiment Laboratory PresentationPPT
05 Creating Stored Procedures
SQL Procedures & Functions
Sql procedures
Procedure n functions
Procedures/functions of rdbms
5. stored procedure and functions
plsql les01
Lecture Notes Unit5 chapter17 Stored procedures and functions
Module04
Relational Database Management System
Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Procedures
Lecture 3.2_Subprogrammm - Function.pptx
Unit 3
Stored procedures
Pl/SQL Procedure,Function & Packages - sub programs
9. DBMS Experiment Laboratory PresentationPPT

More from oracle content (13)

PPTX
Oracle: PLSQL Introduction
PPTX
Oracle : DML
PPTX
Oracle: Programs
PPTX
Oracle: Commands
PPTX
Oracle: Joins
PPTX
Oracle:Cursors
PPTX
Oracle: Control Structures
PPTX
Oracle: Dw Design
PPTX
Oracle: Basic SQL
PPTX
Oracle Warehouse
PPTX
Oracle: Functions
PPT
Oracle: New Plsql
PPTX
Oracle: Fundamental Of Dw
Oracle: PLSQL Introduction
Oracle : DML
Oracle: Programs
Oracle: Commands
Oracle: Joins
Oracle:Cursors
Oracle: Control Structures
Oracle: Dw Design
Oracle: Basic SQL
Oracle Warehouse
Oracle: Functions
Oracle: New Plsql
Oracle: Fundamental Of Dw

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
Approach and Philosophy of On baking technology
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars

Oracle: Procedures

  • 2. 2ProceduresA procedure is a collection of SQL and procedural statements that perform a specific task and are assigned a unique name within the schema and stored in the database.Advantages of Procedures:Dividing the program into smaller manageable unitsStored in compiled form , hence improve performance.Enable creation of reusable code.DBA can grant/revoke privileges to users to access procedures, hence better security.Reduce network traffic as they are stored in the database .
  • 3. 3Types of Procedures There are two kinds of procedures:Anonymous: These procedures do not have a name assigned to them. It is complied each time when the user submits its source code to the database server. Stored : Unlike anonymous, stored procedures have a unique name assigned to them and are stored in the compiled form in the database. NOTE: Only Stored procedures can accept parameters and does not use the DECLARE BLOCK.
  • 4. 4Procedure SyntaxSYNTAX:CREATE [/REPLACE] PROCEDURE procedure_name [(parameter datatype),…...][LANGUAGE { ADA|C|….|SQL}ASStatement 1;…..…… Procedure body. SQL/PLSQL statements….….END;To execute the procedure:EXEC procedure_name;
  • 5. 5Procedure ExampleCREATE OR REPLACE PROCEDURE InfoTable_procAScounter number;c_name varchar2(15);BEGINDBMS_OUTPUT.PUT_LINE('in order');counter :=10;loopselect name into c_name FROM ConTable where ID=counter;DBMS_OUTPUT.PUT_LINE(c);EXIT WHEN counter<1;END LOOP;end;
  • 6. 6FunctionA function is a stored sub-routine that returns one value and as only input parameters.A stored function is same as a procedure except for the procedure keyword is replaced by the keyword function and it carries out a specific operation and returns a value.As functions do not take output parameters it must be assigned to a variable in the program.SYNTAX:CREATE OR REPLACE FUNTION function_name (<parameter list>)RETURN <return_type>ASvariable declarations if any……BEGINStatement1……END
  • 7. 7Function Example CREATE OR REPLACE FUNCTION f1( n IN NUMBER)RETURN NUMBERAS c NUMBER(4); Variable declarationf NUMBER(4);BEGIN c:=1; f:=1;WHILE (c<=n) LOOP Function Bodyf:=f*c; c:=c+1; END LOOP;RETURN f;END; This function when executed calculates the factorial of the parameter n.
  • 8. 8ParametersBoth PROCEDURE or FUNCTION take different parameters. There are three different types of parameters :
  • 9. THANK YOU9THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit: www.dataminingtools.net