--我不明白哪里出错了

CREATE OR REPLACE FUNCTION get_person_membership (IN person_urn CHARACTER VARYING)

   RETURNS TEXT  AS
$BODY$

DECLARE
result text;
urn ALIAS FOR $1;

BEGIN

SELECT INTO result pers.mx_groupmember FROM mt_person AS pers, mxt_recordheader AS rech
WHERE rech.primaryurn = 'urn'
AND rech.entitytype = 'person'
AND rech.logicalserverprefix = 'EA'
AND rech.id = pers.id;
RETURN result;

END;
$BODY$
LANGUAGE plpgsql
VOLATILE
COST 100

最佳答案

我简化了你的问题:
对于您可以使用$1的输入,这将指导您的条件。
如果你不需要其他地方,你可以直接返回你的结果。
从“获取个人会员资格”中选择“*”;

CREATE OR REPLACE FUNCTION get_person_membership (IN person_urn CHARACTER VARYING)
RETURNS TEXT  AS
$BODY$

BEGIN

RETURN (select pers.mx_groupmember --returns single value
FROM mt_person AS pers, mxt_recordheader AS rech
WHERE rech.primaryurn = $1 --input value from person_urn
AND rech.entitytype = 'person'
AND rech.logicalserverprefix = 'EA'
AND rech.id = pers.id);

END;
$BODY$
LANGUAGE plpgsql
VOLATILE
COST 100

09-30 17:08