Oracle SQL, PLSQL, APEX How To's by Dr. S. Raghunathan - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

 

 

 

 

 

 

 

 

 

19-HOW TO CREATE FUNCTION

Functions are forming part of set commands' Functions can return

 

a value to the caller' Functions can be referred directly in the SQL queries' The value is returned through keyword within the function' Let us analyze the function syntax

create or replace function << function-name >>

 

( <<out-variable-name>> IN <<variable-data-type>> )

 

return  <<data-type>>

 

<<variable-name> <<data-type and length>>;

 

begin

 

' ' ' ' '

 

' ' ' ' '

 

RETURN (<<out-variable-name>>); ExCEPTION

WHEN NO-DATA-FOUND THEN

 

RAISE-APPLICATION-ERROR(-20100,

 

'some error messages');

 

end;

 

Now, we will write a complex function and learn some of the newer concepts of sql and concepts of function'