create function in mysql code example
Example 1: create function in postgresql
create [or replace] function function_name(param_list)
returns return_type
language plpgsql
as $$
declare
begin
end;
$$
Example 2: mysql create function
DELIMITER $$
CREATE FUNCTION f_employee_count(p_dept_no INTEGER) RETURNS INTEGER
DETERMINISTIC NO SQL READS SQL DATA
BEGIN
DECLARE v_emp_count INTEGER;
SELECT COUNT(*)
INTO v_emp_count
FROM EMPLOYEES E
WHERE E.DEPT_NO = p_dept_no
GROUP BY DEPARTMENT_NO;
RETURN v_emp_count;
END$$
DELIMITER ;
Example 3: create function in mysql
CREATE FUNCTION `data-management`.checkTags(tags text)
RETURNS text
DETERMINISTIC
BEGIN
return tags ;
END
SELECT * FROM `data-management`.properties p WHERE `data-management`.checkTags(p.tags = 'tag1,absntee')