954
社区成员
发帖
与我相关
我的任务
分享
CREATE OR REPLACE FUNCTION organontype(bpchar) RETURNS integer AS
$BODY$DECLARE
strWhere character(20000);
BEGIN
strWhere := 'select oid'
select strWhere = strWhere ||',max(case tid when''' || tid || ''' then score else 0 end)[' || tid || ']'
from (select distinct tid from (select o.organname as oid,t.name as tid,ot.score from organontype as ot,organ as o,fillquestiontype as t where o.organcode=ot.oid and t.id=ot.tid) as d) as a
strWhere := strWhere || ' from (select o.organname as oid,t.name as tid,ot.score from organ as o,fillquestiontype as t,organontype as ot where o.organcode=ot.oid and t.id=ot.tid) as c group by oid'
strWhere := 'select oid,'|| $1 || ' from (' || strWhere ||') as abc '
return 0;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
参数传的是fillquestiontype的name字段
比如传 '安全'
显示
oid 安全
传 '安全,环保'
显示
oid 安全 环保