【问题标题】:How to update the nested array in json using oracle如何使用 oracle 更新 json 中的嵌套数组
【发布时间】:2022-01-01 16:14:36
【问题描述】:
update sb_layout_defn
set    SB_LAYOUT_DEFN_DATA = json_transform (
                               SB_LAYOUT_DEFN_DATA, 
                               replace '$.filterDefaults.defaultValue' = 'FIRST'
                             )
where  json_exists(
         sb_layout_defn.SB_LAYOUT_DEFN_DATA,
         '$?(@.filterDefaults.defaultValue=="SECOND")'
       );
"screenFilterDefaultDefn":[
  {
    "id":"art-group-id-1",
    "collectionId":"ADVENTURE_WORKS",
    "filterDefaults":[
      {
        "id":"ART-FILTER-DEF-0",
        "defaultValue":"SECOND"
      },
      {
        "id":"ART-FILTER-DEF-1",
        "defaultValue":"PENULT"
      }
    ]
  }
]

我需要更新这里的默认值..

【问题讨论】:

    标签: arrays json oracle parent-child


    【解决方案1】:

    您可以像这样使用JSON_TRANSFORM 语句更新filterDefaults 的第一个数组元素的值:

    UPDATE sb_layout_defn SET SB_LAYOUT_DEFN_DATA = JSON_TRANSFORM(SB_LAYOUT_DEFN_DATA, SET '$.screenFilterDefaultDefn[0].filterDefaults[0].defaultValue' = 'FIRST' );
    

    【讨论】:

      猜你喜欢
      • 2015-08-04
      • 2019-12-26
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 2021-04-17
      • 1970-01-01
      • 2019-06-08
      • 2020-10-09
      相关资源
      最近更新 更多