SlideShare a Scribd company logo
1 of 2
SUB PROGRAMS
Sub programs are the named PL SQL blocks that can take parameters and can be invoked.

Types:

Procedures

Functions

Function-

 Functions are like procedures that perform action. The only difference is that functions
return a value.

Types: local and stored

     1. Local functions- That are defined in declaration section of the program.

Example:-

SQL> ed great

Declare

A number;

B number;

Result number;

Function great (A number, B number) return number

As

C number;

Begin

C=A*B

Return(C);

End product;

Begin

A:= &A;

B:= &B;

Result:= great(A,B);
dbms_output.put_line(‘product =’ ||result);

end;

/

     2. Stored functions- that are stored in oracle engine.

Example:-

SQL> ed great

Create or replace function great (A number, B number, C number) return number

As

Begin

If (A>B and A>C) then

Return A;

Elsif (A<B and C<B) then

Return B;

Else

Return C;

Endif;

End great;

/

More Related Content

What's hot

Write a program that accepts percentage from the user and displays its grade ...
Write a program that accepts percentage from the user and displays its grade ...Write a program that accepts percentage from the user and displays its grade ...
Write a program that accepts percentage from the user and displays its grade ...Farwa Aqeel
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++Praveen M Jigajinni
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++sunny khan
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Himanshu Kaushik
 
A quick introduction to c programming
A quick introduction to c programmingA quick introduction to c programming
A quick introduction to c programmingMohit Patodia
 
Presentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurPresentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurThakurkirtika
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOPjason_scorebig
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Deepak Singh
 

What's hot (20)

Operators
OperatorsOperators
Operators
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
 
Write a program that accepts percentage from the user and displays its grade ...
Write a program that accepts percentage from the user and displays its grade ...Write a program that accepts percentage from the user and displays its grade ...
Write a program that accepts percentage from the user and displays its grade ...
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Operators in C#
Operators in C#Operators in C#
Operators in C#
 
Functions in c++,
Functions in c++,Functions in c++,
Functions in c++,
 
Coper in C
Coper in CCoper in C
Coper in C
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Operator of C language
Operator of C languageOperator of C language
Operator of C language
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++
 
structure of a c program
structure of a c programstructure of a c program
structure of a c program
 
Static variables
Static variablesStatic variables
Static variables
 
A quick introduction to c programming
A quick introduction to c programmingA quick introduction to c programming
A quick introduction to c programming
 
Presentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurPresentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakur
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOP
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
Csc240 -lecture_5
Csc240  -lecture_5Csc240  -lecture_5
Csc240 -lecture_5
 
201801 CSE240 Lecture 06
201801 CSE240 Lecture 06201801 CSE240 Lecture 06
201801 CSE240 Lecture 06
 
LAB 1 Report.docx
LAB 1 Report.docxLAB 1 Report.docx
LAB 1 Report.docx
 

Similar to 1 (20)

Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
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
 
Procedure n functions
Procedure n functionsProcedure n functions
Procedure n functions
 
Unit 3
Unit 3Unit 3
Unit 3
 
DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
Verilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSVerilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONS
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 
SQl
SQlSQl
SQl
 
Verilog Tasks and functions
Verilog Tasks and functionsVerilog Tasks and functions
Verilog Tasks and functions
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
SQL Procedures & Functions
SQL Procedures & FunctionsSQL Procedures & Functions
SQL Procedures & Functions
 
Function
Function Function
Function
 

1

  • 1. SUB PROGRAMS Sub programs are the named PL SQL blocks that can take parameters and can be invoked. Types: Procedures Functions Function- Functions are like procedures that perform action. The only difference is that functions return a value. Types: local and stored 1. Local functions- That are defined in declaration section of the program. Example:- SQL> ed great Declare A number; B number; Result number; Function great (A number, B number) return number As C number; Begin C=A*B Return(C); End product; Begin A:= &A; B:= &B; Result:= great(A,B);
  • 2. dbms_output.put_line(‘product =’ ||result); end; / 2. Stored functions- that are stored in oracle engine. Example:- SQL> ed great Create or replace function great (A number, B number, C number) return number As Begin If (A>B and A>C) then Return A; Elsif (A<B and C<B) then Return B; Else Return C; Endif; End great; /