如何修复Postgres 12.3错误:在CASE中不允许使用set-turning函数

问题描述

我刚刚将Postgresql从9.5更新到了12.3,现在我从特定的查询中收到此错误消息:

() => void

我已经在查询中指出了错误的位置。

查询1:

ERROR: set-returning functions are not allowed in CASE

查询2:

select attribute_id,attribute_input_type,string_agg(attr_value,','),false,attribute_predefined_value,attribute_lgd_location_type
from (select distinct
             B.attribute_id,B.attribute_input_type,CASE WHEN B.attribute_input_type in ('lgdHierarchy','lgdDepartment')
                  THEN A.attr_value
                  ELSE case when B.attribute_input_type in ('checkBox','listBox')
/* error is here -> */      THEN Split_part(unnest(string_to_array(A.attr_value,')),'~',1)
                            else Split_part(A.attr_value,1)
                       end
             END attr_value,B.attribute_predefined_value,B.attribute_lgd_location_type
      from (select json_data.key :: integer attribute_id,json_data.value as attr_value
            from sp_custom.application_processing_json a,json_each_text(a.initiated_data->'application_form_attributes') AS json_data
            where a.application_id = 1162
           ) A,temp_output_attr_list ot,schm_sp.appl_attribute_mast B
      where A.attribute_id = ot.primary_attribute_id
        and ot.find_flag = false
        and A.attribute_id = B.attribute_id
        and B.attribute_input_type <> 'fieldset'
     ) X
group by attribute_id,attribute_lgd_location_type;

这两个查询都从JSON获取数据。

两个查询在Postgrsql9.5中都可以正常工作,但是Upgrade Postgresql12.3显示错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)