What is a stored function Where is it located How can it be

What is a stored function? Where is it located? How can it be used? Explain

Solution

stored function :-

stored function is nothing but block of code similar to stored procedure which will perform some operation and returns a single value to the user. stored functions are also called as user defined functions.

Syntax :-

CREATE OR REPLACE FUNCTION FUNCTION_NAME(PARAMETER DATATYPE)

RETURN(PARAMETER/VARIABLE DATATYPE)

IS/AS

VARIABLE DECLARATION ;

BEGIN

CODE/STATEMENT ;

RETURN(PARAMETER/VARIABLE DATATYPE) ;

END;

/

Example :-

A stored function to return the cube of a given variable value :-

CREATE OR REPLACE FUNCTION F1(X INT)

RETURN INT

IS

BEGIN

RETURN X*X*X ;

END ;

/

Output :-

SELECT F1(5) FROM DUAL ; // Function Call

F1(5)

125.

What is a stored function? Where is it located? How can it be used? ExplainSolutionstored function :- stored function is nothing but block of code similar to st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site