SlideShare una empresa de Scribd logo
1 de 9
1 Using ORACLE® Procedures and Functions
2 Procedures A 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 units Stored 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 Types 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 Procedure Syntax SYNTAX: CREATE [/REPLACE] PROCEDURE procedure_name [(parameter datatype),…...] [LANGUAGE { ADA|C|….|SQL} AS Statement 1; ….. ……			    Procedure body.	 SQL/PLSQL statements …. …. END; To execute the procedure: EXEC procedure_name;
5 Procedure Example CREATE OR REPLACE PROCEDURE InfoTable_proc AS counter number; c_name varchar2(15); BEGIN DBMS_OUTPUT.PUT_LINE('in order'); counter :=10; loop select name into c_name FROM ConTable where ID=counter; DBMS_OUTPUT.PUT_LINE(c); EXIT WHEN counter<1; END LOOP; end;
6 Function A 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> AS variable declarations if any… … BEGIN Statement1… … END
7 Function Example  CREATE OR REPLACE FUNCTION f1( n IN NUMBER) RETURN NUMBER AS 	c NUMBER(4);			Variable declaration f NUMBER(4); BEGIN 	c:=1; 	f:=1; WHILE (c<=n) 	LOOP				  Function Body f:=f*c; 		c:=c+1; 	END LOOP; RETURN f; END; 	    This function when executed calculates the factorial of the parameter n.
8 Parameters Both PROCEDURE or FUNCTION take different parameters. There are three different types of parameters :
THANK YOU 9 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit:   www.dataminingtools.net

Más contenido relacionado

La actualidad más candente

Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sqlÑirmal Tatiwal
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals INick Buytaert
 
ORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSmohdoracle
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, proceduresVaibhav Kathuria
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 
Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02Thuan Nguyen
 
Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Thuan Nguyen
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sqlSushil Mishra
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsqlSid Xing
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideSrinimf-Slides
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracleSuhel Firdus
 

La actualidad más candente (19)

PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
ORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERS
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Pl sql-ch2
Pl sql-ch2Pl sql-ch2
Pl sql-ch2
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02
 
Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15
 
ORACLE PL/SQL
ORACLE PL/SQLORACLE PL/SQL
ORACLE PL/SQL
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 
Plsql
PlsqlPlsql
Plsql
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 

Destacado

Transportation Marketplace
Transportation MarketplaceTransportation Marketplace
Transportation MarketplaceChris Sheffer
 
사이버컴과 네트워크분석 9주차 2
사이버컴과 네트워크분석 9주차 2사이버컴과 네트워크분석 9주차 2
사이버컴과 네트워크분석 9주차 2Han Woo PARK
 
Zahid latif khan securities (pvt) ltd
Zahid latif khan securities (pvt) ltdZahid latif khan securities (pvt) ltd
Zahid latif khan securities (pvt) ltdFuzael Amin
 
최종과제 윤아영지혜린
최종과제 윤아영지혜린최종과제 윤아영지혜린
최종과제 윤아영지혜린hyelin ji
 
Khumbi ke kasht Key Marahial A Presentation By Mr Allah Dad khan Former Dir...
Khumbi ke kasht  Key Marahial  A Presentation By Mr Allah Dad khan Former Dir...Khumbi ke kasht  Key Marahial  A Presentation By Mr Allah Dad khan Former Dir...
Khumbi ke kasht Key Marahial A Presentation By Mr Allah Dad khan Former Dir...Mr.Allah Dad Khan
 
Guía de aprendizaje 2: certificados y comunidad
Guía de aprendizaje 2: certificados y comunidadGuía de aprendizaje 2: certificados y comunidad
Guía de aprendizaje 2: certificados y comunidadOriol Borras Gene
 
Heather growth marketing conf 2016
Heather growth marketing conf 2016Heather growth marketing conf 2016
Heather growth marketing conf 2016Vasil Azarov
 
사이버컴과 네트워크분석 7주차 1
사이버컴과 네트워크분석 7주차 1사이버컴과 네트워크분석 7주차 1
사이버컴과 네트워크분석 7주차 1Han Woo PARK
 
OpenBar for social sales collaboration - Massimo Barboni
OpenBar for social sales collaboration - Massimo BarboniOpenBar for social sales collaboration - Massimo Barboni
OpenBar for social sales collaboration - Massimo BarboniOpenKnowledge srl
 
Vincent gmc growth hacking ultimate version october 2016
Vincent gmc growth hacking  ultimate version october 2016Vincent gmc growth hacking  ultimate version october 2016
Vincent gmc growth hacking ultimate version october 2016Vasil Azarov
 
Informationsecurity
InformationsecurityInformationsecurity
InformationsecurityUmme habiba
 

Destacado (16)

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

Similar a Oracle: Procedures

Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbmsjain.pralabh
 
Oracle - Program with PL/SQL - Lession 11
Oracle - Program with PL/SQL - Lession 11Oracle - Program with PL/SQL - Lession 11
Oracle - Program with PL/SQL - Lession 11Thuan Nguyen
 
Db Triggers05ch
Db Triggers05chDb Triggers05ch
Db Triggers05chtheo_10
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management Systemsweetysweety8
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
MS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And ProceduresMS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Proceduressqlserver content
 
MS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And ProceduresMS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Proceduressqlserver content
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14Syed Asrarali
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programmingRushdi Shams
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function Prof.Nilesh Magar
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 

Similar a Oracle: Procedures (20)

Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
 
Procedure n functions
Procedure n functionsProcedure n functions
Procedure n functions
 
Oracle - Program with PL/SQL - Lession 11
Oracle - Program with PL/SQL - Lession 11Oracle - Program with PL/SQL - Lession 11
Oracle - Program with PL/SQL - Lession 11
 
Db Triggers05ch
Db Triggers05chDb Triggers05ch
Db Triggers05ch
 
Module04
Module04Module04
Module04
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
SQL Procedures & Functions
SQL Procedures & FunctionsSQL Procedures & Functions
SQL Procedures & Functions
 
Store programs
Store programsStore programs
Store programs
 
Sql Functions And Procedures
Sql Functions And ProceduresSql Functions And Procedures
Sql Functions And Procedures
 
MS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And ProceduresMS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Procedures
 
MS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And ProceduresMS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Procedures
 
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
 
Intro to tsql
Intro to tsqlIntro to tsql
Intro to tsql
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 

Más de oracle content

Más de oracle content (13)

Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oracle: Programs
Oracle: ProgramsOracle: Programs
Oracle: Programs
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Oracle: Control Structures
Oracle:  Control StructuresOracle:  Control Structures
Oracle: Control Structures
 
Oracle: Dw Design
Oracle: Dw DesignOracle: Dw Design
Oracle: Dw Design
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle Warehouse
Oracle WarehouseOracle Warehouse
Oracle Warehouse
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle: New Plsql
Oracle: New PlsqlOracle: New Plsql
Oracle: New Plsql
 
Oracle: Fundamental Of Dw
Oracle: Fundamental Of DwOracle: Fundamental Of Dw
Oracle: Fundamental Of Dw
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Oracle: Procedures

  • 1. 1 Using ORACLE® Procedures and Functions
  • 2. 2 Procedures A 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 units Stored 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. 3 Types 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. 4 Procedure Syntax SYNTAX: CREATE [/REPLACE] PROCEDURE procedure_name [(parameter datatype),…...] [LANGUAGE { ADA|C|….|SQL} AS Statement 1; ….. …… Procedure body. SQL/PLSQL statements …. …. END; To execute the procedure: EXEC procedure_name;
  • 5. 5 Procedure Example CREATE OR REPLACE PROCEDURE InfoTable_proc AS counter number; c_name varchar2(15); BEGIN DBMS_OUTPUT.PUT_LINE('in order'); counter :=10; loop select name into c_name FROM ConTable where ID=counter; DBMS_OUTPUT.PUT_LINE(c); EXIT WHEN counter<1; END LOOP; end;
  • 6. 6 Function A 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> AS variable declarations if any… … BEGIN Statement1… … END
  • 7. 7 Function Example CREATE OR REPLACE FUNCTION f1( n IN NUMBER) RETURN NUMBER AS c NUMBER(4); Variable declaration f NUMBER(4); BEGIN c:=1; f:=1; WHILE (c<=n) LOOP Function Body f:=f*c; c:=c+1; END LOOP; RETURN f; END; This function when executed calculates the factorial of the parameter n.
  • 8. 8 Parameters Both PROCEDURE or FUNCTION take different parameters. There are three different types of parameters :
  • 9. THANK YOU 9 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit: www.dataminingtools.net