Oracle Create Function
Oracle Create Function
To create a standalone stored function uses the CREATE FUNCTION statement.
Create Function syntax
CREATE OR REPLACE FUNCTION function_name (arg1 data_type, ...) RETURN data_type IS BEGIN .... END; /
Create Function example
CREATE FUNCTION get_name (p_id NUMBER) RETURN VARCHAR2 IS v_name varchar2(255); BEGIN SELECT name INTO v_name FROM CUSTOMERS WHERE id=p_id; RETURN v_name; END; /
Call Function example
SELECT get_name(3) FROM dual;