1create [or replace] function function_name(param_list)
2 returns return_type
3 language plpgsql
4as $$
5declare
6-- variable declaration
7begin
8 -- logic
9end;
10$$
1-- MySQL
2
3-- example
4DELIMITER $$
5CREATE FUNCTION f_employee_count(p_dept_no INTEGER) RETURNS INTEGER
6 DETERMINISTIC NO SQL READS SQL DATA
7 BEGIN
8 DECLARE v_emp_count INTEGER;
9
10 SELECT COUNT(*)
11 INTO v_emp_count
12 FROM EMPLOYEES E
13 WHERE E.DEPT_NO = p_dept_no
14 GROUP BY DEPARTMENT_NO;
15
16 RETURN v_emp_count;
17END$$
18DELIMITER ;
19
20/* syntax:
21DELIMITER $$
22CREATE FUNCTION <Your-procedure-name>(<arguments>) RETURNS <date-type>
23 DETERMINISTIC NO SQL READS SQL DATA
24 BEGIN
25 DECLARE <variable-name> <data-type>
26
27 <Code-that-sets-the-output-variable>;
28
29 RETURN <variable-name>;
30END$$
31DELIMITER ;
32*/
1// created function checkTags
2CREATE FUNCTION `data-management`.checkTags(tags text)
3RETURNS text
4DETERMINISTIC
5BEGIN
6return tags ;
7END
8
9
10// queries according to it
11SELECT * FROM `data-management`.properties p WHERE `data-management`.checkTags(p.tags = 'tag1,absntee')