0% found this document useful (0 votes)
6 views

Strored Functions

Uploaded by

Dhavan Ravuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Strored Functions

Uploaded by

Dhavan Ravuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

PL/SQL Functions:

* PL/SQL Functions are also called Stored functions


* Used to perform an operation when we call it.
* Functions are callable objects
* Function can return a value whereas procedures can't return a value.
* to create function we have to use "create or replace Function " statement
syntax:
create or replace Function functionname(arg1 type, ....)
return type
is / as
begin
statements ;
return value;
end;
A procedure must have arguments (variables to store data)
ex:
create or replace function fun1(n number)
return number
as
begin
return n+20;
end;

How to call a Function?


There are two ways to call a function
1.Using select
* Select statement will call and execute a function
syn:
sql>select functionname(data1,...) from dual;
ex:
sql>select fun1(20) from dual;
Fun1(20)
--------------
40

2.using PL/SQL Block:


* define a pl/sql block with function call to execute it.
ex:
begin
dbms_output.put_line(fun1(22));
end;

You might also like