SlideShare a Scribd company logo
S.Rose
SAC college
Functions in oracle
Function
What is a Function in PL/SQL?
A function are named PL/SQL Block. It is similar to
a procedure. The major difference between a procedure and a
function is, a function must always return a value, but a
procedure may or may not return a value.
Structure of function
stored functions 3 sections
1.declaration section-declaration of variables and constants
2.executable section-pl/sql statements which perform specific
task
3.exception handling section-the error occuring in executable
part can be handled in this section
SYNTAX
CREATE [OR REPLACE] FUNCTION function_name
[ (parameter [,parameter]) ]
RETURN return_datatype
IS | AS
[declaration_section]
BEGIN
executable_section
[EXCEPTION
exception_section]
END [function_name];
Example
CREATE [OR REPLACE] FUNCTION fa(m number)
RETURN number
IS
f number:=1;
BEGIN
for I in 1….m
Loop
F:=f*I;
End loop;
return f;
End;

More Related Content

PPTX
Orcal FUNCTIONS
PPT
Oracle PL sql 3
PDF
Packages - PL/SQL
PPT
PL/SQL
PPTX
Function and types
PPTX
Oracle: Control Structures
DOCX
Functions oracle (pl/sql)
Orcal FUNCTIONS
Oracle PL sql 3
Packages - PL/SQL
PL/SQL
Function and types
Oracle: Control Structures
Functions oracle (pl/sql)

What's hot (17)

PPTX
Procedure and Functions in pl/sql
DOCX
Forall & bulk binds
PPT
PL/SQL Introduction and Concepts
PPTX
PL/SQL - CURSORS
PPTX
Oracle: PLSQL Introduction
PPTX
Procedure n functions
PPTX
Sql tutorial
PPT
Module04
PPTX
Oracle: Procedures
DOC
4. function
PPT
15 functions
PPTX
Oracle: Basic SQL
PPT
PLSQL Cursors
PPT
PPTX
Function & Recursion
PDF
Programming in Oracle with PL/SQL
PPT
DAC training-batch -2020(PLSQL)
Procedure and Functions in pl/sql
Forall & bulk binds
PL/SQL Introduction and Concepts
PL/SQL - CURSORS
Oracle: PLSQL Introduction
Procedure n functions
Sql tutorial
Module04
Oracle: Procedures
4. function
15 functions
Oracle: Basic SQL
PLSQL Cursors
Function & Recursion
Programming in Oracle with PL/SQL
DAC training-batch -2020(PLSQL)
Ad

Similar to Function (20)

PDF
SQL Procedures & Functions
PPT
plsql les02
PPTX
Oracle: Procedures
PPT
05 Creating Stored Procedures
PDF
Dbms 2011
PPTX
5. stored procedure and functions
PDF
Sql functions
PPTX
Plsql guide 2
PPTX
Lecture 3.2_Subprogrammm - Function.pptx
PPT
PPT
SQL / PL
PPTX
PLSQL.pptx
PDF
Lecture Notes Unit5 chapter17 Stored procedures and functions
PPTX
STORED FUNCTION IN PLStructuredQueryL.pptx
PPS
Procedures/functions of rdbms
PPTX
Understanding pass by value and pass by reference is essential for effective ...
PPTX
Unit 3
PDF
RDBMS - UNIT 5.pdf ,UNIT -1 AND UNIT 5 NIT 4
PPTX
Pl/SQL Procedure,Function & Packages - sub programs
PDF
Unit 4 rdbms study_material
SQL Procedures & Functions
plsql les02
Oracle: Procedures
05 Creating Stored Procedures
Dbms 2011
5. stored procedure and functions
Sql functions
Plsql guide 2
Lecture 3.2_Subprogrammm - Function.pptx
SQL / PL
PLSQL.pptx
Lecture Notes Unit5 chapter17 Stored procedures and functions
STORED FUNCTION IN PLStructuredQueryL.pptx
Procedures/functions of rdbms
Understanding pass by value and pass by reference is essential for effective ...
Unit 3
RDBMS - UNIT 5.pdf ,UNIT -1 AND UNIT 5 NIT 4
Pl/SQL Procedure,Function & Packages - sub programs
Unit 4 rdbms study_material
Ad

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Getting Started with Data Integration: FME Form 101
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Tartificialntelligence_presentation.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
project resource management chapter-09.pdf
Approach and Philosophy of On baking technology
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TLE Review Electricity (Electricity).pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A Presentation on Artificial Intelligence
cloud_computing_Infrastucture_as_cloud_p
Getting Started with Data Integration: FME Form 101
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Touch Screen Technology
Hindi spoken digit analysis for native and non-native speakers
MIND Revenue Release Quarter 2 2025 Press Release
Tartificialntelligence_presentation.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
project resource management chapter-09.pdf

Function

  • 3. Function What is a Function in PL/SQL? A function are named PL/SQL Block. It is similar to a procedure. The major difference between a procedure and a function is, a function must always return a value, but a procedure may or may not return a value. Structure of function stored functions 3 sections 1.declaration section-declaration of variables and constants 2.executable section-pl/sql statements which perform specific task 3.exception handling section-the error occuring in executable part can be handled in this section
  • 4. SYNTAX CREATE [OR REPLACE] FUNCTION function_name [ (parameter [,parameter]) ] RETURN return_datatype IS | AS [declaration_section] BEGIN executable_section [EXCEPTION exception_section] END [function_name];
  • 5. Example CREATE [OR REPLACE] FUNCTION fa(m number) RETURN number IS f number:=1; BEGIN for I in 1….m Loop F:=f*I; End loop; return f; End;