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)

PPS
Procedures/functions of rdbms
PPTX
Procedure n functions
PDF
Lecture Notes Unit5 chapter17 Stored procedures and functions
PPT
Db Triggers05ch
PPT
Module04
PPTX
Relational Database Management System
PPTX
STORED-PROCEDURE.pptxjsjjdjdjcjcjdkksksksk
PPTX
Lecture 3.2_Subprogrammm - Function.pptx
PPTX
Lecture 3.2_Subprogrammm - Function.pptx
PPT
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
PDF
SQL Procedures & Functions
PPT
Store programs
PPTX
Sql Functions And Procedures
PPTX
MS SQLSERVER:Sql Functions And Procedures
PPTX
MS SQL SERVER: Sql Functions And Procedures
PPT
Procedures andcursors
PPTX
ch5-Advanced SQL_ database management .pptx
PPT
Intro to tsql
PPT
Intro to tsql unit 14
PPTX
Pl/SQL Procedure,Function & Packages - sub programs
Procedures/functions of rdbms
Procedure n functions
Lecture Notes Unit5 chapter17 Stored procedures and functions
Db Triggers05ch
Module04
Relational Database Management System
STORED-PROCEDURE.pptxjsjjdjdjcjcjdkksksksk
Lecture 3.2_Subprogrammm - Function.pptx
Lecture 3.2_Subprogrammm - Function.pptx
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
SQL Procedures & Functions
Store programs
Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Procedures
Procedures andcursors
ch5-Advanced SQL_ database management .pptx
Intro to tsql
Intro to tsql unit 14
Pl/SQL Procedure,Function & Packages - sub programs

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)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
August Patch Tuesday
PPTX
Machine Learning_overview_presentation.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Tartificialntelligence_presentation.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
A Presentation on Artificial Intelligence
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Machine learning based COVID-19 study performance prediction
Univ-Connecticut-ChatGPT-Presentaion.pdf
Spectral efficient network and resource selection model in 5G networks
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TLE Review Electricity (Electricity).pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
August Patch Tuesday
Machine Learning_overview_presentation.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Tartificialntelligence_presentation.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Mobile App Security Testing_ A Comprehensive Guide.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
A Presentation on Artificial Intelligence
OMC Textile Division Presentation 2021.pptx
cloud_computing_Infrastucture_as_cloud_p
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine learning based COVID-19 study performance prediction

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