【DM版本】:8
【操作系统】:ubuntu18.04
【CPU】: X86_64
【问题描述】*:我将mysql的一个函数改写了之后,一直显示编译失败,报错数据类型不匹配,不知道哪儿出了问题.,下面是sql,希望大佬能解答一下,谢谢啦
CREATE FUNCTION "dataease-wei"."GET_V_AUTH_MODEL_WITH_PRIVILEGE"(userId longtext ,modelType varchar(255) ,privilegeType varchar(255) ) RETURN longtext AS
oTempLeafIds longtext ;
BEGIN
select wm_concat("auth_source") into oTempLeafIds from (
SELECT
"sys_auth"."auth_source_type",
(cast("sys_auth"."auth_source" as longtext))
FROM
"sys_auth"
LEFT JOIN "sys_auth_detail" ON "sys_auth"."id" = "sys_auth_detail"."auth_id"
WHERE
"sys_auth_detail"."privilege_type" = privilegeType
and "sys_auth"."auth_source_type" = modelType
AND (
(
"sys_auth"."auth_target_type" = 'dept'
AND "sys_auth"."auth_target" in ( SELECT "dept_id" FROM "sys_user" WHERE "user_id" = userId )
)
OR (
"sys_auth"."auth_target_type" = 'user'
AND "sys_auth"."auth_target" = userId
)
OR (
"sys_auth"."auth_target_type" = 'role'
AND "sys_auth"."auth_target" in ( SELECT "role_id" FROM "sys_users_roles" WHERE "user_id" = userId )
)
OR (1 = ( SELECT "is_admin" FROM "sys_user" WHERE "user_id" = userId ))
)
GROUP BY
"sys_auth"."auth_source_type",
"sys_auth"."auth_source"
having (sum( "sys_auth_detail"."privilege_value" )> 0 or 1 = ( SELECT "is_admin" FROM "sys_user" WHERE "user_id" = userId ))) temp;
RETURN oTempLeafIds;
END;
请至少给出这个函数涉及到的相关表的表定义吧。