PL/SQL Function


Prev Tutorial Next Tutorial

PL/SQL Function

A PL/SQL Function is a self control block which is used to perform some specific task.

Difference between function and procedure

The main 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.

Syntax

CREATE OR REPLACE FUNCTION function_name(parameters)
RETURN return_datatype;  
IS  
Declaration_section  
BEGIN  
Execution_section 
Return return_variable;  
EXCEPTION  
exception section  
Return return_variable;  
END; 

Example of function to add two number

Example

create or replace function add(a number, b number)
return number
is
number;
begin;
a:=10;
b:=20;
c=a+b;
return c;
end;

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements