create function in postgresql
create [or replace] function function_name(param_list)
returns return_type
language plpgsql
as $$
declare
-- variable declaration
begin
-- logic
end;
$$
create function in postgresql
create [or replace] function function_name(param_list)
returns return_type
language plpgsql
as $$
declare
-- variable declaration
begin
-- logic
end;
$$
mysql create function
-- MySQL
-- example
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 ;
/* syntax:
DELIMITER $$
CREATE FUNCTION <Your-procedure-name>(<arguments>) RETURNS <date-type>
DETERMINISTIC NO SQL READS SQL DATA
BEGIN
DECLARE <variable-name> <data-type>
<Code-that-sets-the-output-variable>;
RETURN <variable-name>;
END$$
DELIMITER ;
*/
create function in mysql
// created function checkTags
CREATE FUNCTION `data-management`.checkTags(tags text)
RETURNS text
DETERMINISTIC
BEGIN
return tags ;
END
// queries according to it
SELECT * FROM `data-management`.properties p WHERE `data-management`.checkTags(p.tags = 'tag1,absntee')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us