Create custom function used in ORACLE SQL