oracle获取json第一层的key,ORACLE - JSON到键值对表(ORACLE - JSON To Key Value Pair Table)

ORACLE - JSON到键值对表(ORACLE - JSON To Key Value Pair Table)

有没有办法从CLOB Json列获取具有键/值对的表?

这里的想法是以动态的方式获得这些价值。 因为CLOB列并不总是包含相同的结构。

我已经创建了一个执行此操作的函数,但是因为它实际上解析了json字符串,所以当我们在具有许多记录的表中使用它时它非常慢。 而且速度非常慢,我的意思是每秒2-5条记录,我知道这很糟糕。

Oracle工具(v.12c)没有提供获取json标记/值的动态方法,我们总是指定路径。

我一直在四处挖掘,没有任何运气。 有什么想法吗?

Is there any way to obtain a table with key/value pairs from a CLOB Json Column?

The idea here is to get these values, on a dynamic way. Because the CLOB column does not always contain the same structure.

I've created a function that does this, however since it literally parses the json string, when we use it in a table with many records its very slow. And by very slow I mean like 2-5 records per second, i know it's terrible.

The Oracle tools (v.12c) do not provide a dynamic way to obtain the json tags/values, we have always to specify the paths.

I've been digging all around without any luck. Any thoughts?

原文:https://stackoverflow.com/questions/42702150

2020-03-05 15:03

满意答案

12.2包含一组PL / SQL对象,可用于构建类似JSON文档结构的DOM。 然后,您可以使用对象上的方法提取密钥列表等。 查看12.2 doc中的JSON_OBJECT_T,JSON_ARRAY_T等,可以像这样使用..

SQL> create or replace type NV_PAIR_T as object (

2 NAME VARCHAR2(32),

3 VALUE VARCHAR2(32)

4 )

5 /

Type created.

SQL> create or replace type NV_PAIR_TABLE as TABLE of NV_PAIR_T

2 /

Type created.

SQL> create or replace function GET_KEY_VALUES(P_JSON_DOC VARCHAR2)

2 return NV_PAIR_TABLE PIPELINED

3 as

4 JO JSON_OBJECT_T := JSON_OBJECT_T(P_JSON_DOC);

5 JO_KEYS JSON_KEY_LIST := JO.get_keys();

6 begin

7

8 for i in 1..JO_KEYS.count loop

9 pipe row (NV_PAIR_T(JO_KEYS(i),JO.get_string(JO_KEY

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值