Hi ,The SQL CREATE FUNCTION statement is used to create stored functions that are stored in an Oracledatabase. A procedure or function is similar to a miniature program. Usually if we would want to get an output while passing an input , function would be widely used.As always I like to give a scenario where this can be usedScenario: There is an application that usually runs a large piece of SQL and then based on the output decides the next steps of the process. With time the SQL code was larger than the application size and wanted an easier route where if a value is passed , it can search the database and provide an output which can be displayed in the application. This example below is based on Oracle Database.
select COLUMN into V_OUTPUT from TABLE_NAME where COLUMN= V_INPUT ;
RETURN (V_OUTPUT );
END SCHEMA_NAME.FUNCTION_NAME;
Here highlighted in blue is where you can edit and reuse the code . Also, in this case column value gets stored in variable V_OUTPUT based on the filter condition passed in V_INPUT.
select SCHEMA_NAME.FUNCTION_NAME(123) from dual;
You can apply the function in you select statement to return an output.
Thanks
Jethin Abraham