将SQL XML CASE语句转换为SQL JSON



需要帮助将包含case语句的xmlelement的SQL查询转换为JSON。

case 
when db_field1 = '1' then
xmlelement(name "value", 'response1')
when db_field2 - '2' then
xmlelement(name "value", 'response2')
else 
xmlelement(name "value", '')
end

尝试过这样的东西:

json_object (
case 
when db_field1 = '1' then
'value' is 'response1'
when db_field2 - '2' then
'value' is 'response2'
else 
'value' is null
end
)

已解决:
JSON语法的格式为off"键":"值";所以这是正确的方式。在此示例中,信息是用于存储此数据的字段。

json_object (
'information' is 
case when db_field1 = '1' then 'response1'
when db_field2 - '2' then 'response2'
else null
end 
)

最新更新