我正在尝试使用dbeaver在postgresql db上创建函数。但是当试图保存功能时,我得到了错误。它说“在“返回”处或附近的语法错误”。也许有人会看到问题出在哪里。
CREATE OR REPLACE FUNCTION public.concept_children_by_id(concept_id bigint)
RETURNS TABLE(concept_description character varying, component_id bigint, father_id bigint, curr_level integer)
LANGUAGE plpgsql
AS $function$
BEGIN
WITH RECURSIVE OURCTE(component_id, father_id, curren_level) AS
(
SELECT
rel."sourceId",
rel."destinationId",
1::integer
FROM
en."sct2_Relationship_Snapshot_INT" AS rel
WHERE
rel."destinationId" = concept_id
AND
rel.active = '1'
AND
rel."typeId" = 116680003
UNION ALL
SELECT
e."sourceId",
e."destinationId",
rl.curren_level + '1'
FROM
OURCTE rl,
en."sct2_Relationship_Snapshot_INT" e
WHERE
e."destinationId" = rl."component_id"
AND
e.active = '1'
AND
e."typeId" = 116680003
)
RETURN QUERY
SELECT DISTINCT
des.term,
O.component_id,
O.father_id,
O.curren_level
FROM OURCTE O
INNER JOIN en."sct2_Description_Snapshot-en_INT" des ON (O.component_id = des."conceptId")
WHERE
des."typeId" = 900000000000003001;
ORDER BY curren_level;
RETURN;
END;
$function$