From a03742f48136cbecd2ca3bf29c89c775db24856e Mon Sep 17 00:00:00 2001 From: dataprince Date: Tue, 26 Dec 2023 10:26:37 +0800 Subject: [PATCH] =?UTF-8?q?postgresql=E5=88=9B=E5=BB=BA=E4=BA=8E=E4=B8=8Em?= =?UTF-8?q?ysql=E7=AD=89=E6=95=88=E7=9A=84=E7=9A=84find=5Fin=5Fset?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/sql/postgresql/update.sql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/script/sql/postgresql/update.sql b/script/sql/postgresql/update.sql index c7e5af9..854029d 100644 --- a/script/sql/postgresql/update.sql +++ b/script/sql/postgresql/update.sql @@ -53,3 +53,24 @@ insert into sys_menu values('1621', '配置添加', '118', '6', '#', '', '', '1' insert into sys_menu values('1622', '配置编辑', '118', '6', '#', '', '', '1', '0', 'F', '0', '0', 'system:ossConfig:edit', '#', 1, now(), null, null, ''); insert into sys_menu values('1623', '配置删除', '118', '6', '#', '', '', '1', '0', 'F', '0', '0', 'system:ossConfig:remove', '#', 1, now(), null, null, ''); +--postgresql创建于与mysql等效的的find_in_set函数 +CREATE OR REPLACE FUNCTION find_in_set( + value anyelement, + string_list text) + RETURNS integer + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + AS $BODY$ + DECLARE +position INTEGER; +BEGIN + IF string_list = '' THEN + RETURN 0; +ELSE + position := array_position(string_to_array(string_list, ','), value::TEXT); +RETURN position; +END IF; +END; +$BODY$; +