从CLOB获取特定数据

时间:2017-11-19 01:16:56

标签: oracle

我在CLOB列中有以下数据,我希望从以下数据中获取xyz.comDOMAIN NAME LIST不会改变,并且会一直相同

{
    "OBJECT ID":"71864756",
    "OBJECT NAME":"MESSENGER",
    "PARENT ID":"71865529",
    "OBJECT STATUS":"O",
    "WHITE LISTED":"N",
    "LAST UPLOAD":"",
    "PARENT CLASS":"ORDER",
    "IS A LINK OBJECT IND":"N",
    "AOL IM FEDERATION":"false",
    "ATTRIBUTE 1":"0",
    "ATTRIBUTE 2":"0",
    "ATTRIBUTE 3":"0",
    "ATTRIBUTE 4":"0",
    "ATTRIBUTE 5":"0",
    "CLASSIC CENTER INTEGRATION URL":"",
    "COMMENTS":"",
    "DISPLAY NAME":"",
    "DOMAIN NAME LIST":"xyz.com",
    "ICON NAME":"SERVICE_16.PNG",
    "IM LICENSES":"500",
}

请使用dbms_lob.substr .....

帮助我

1 个答案:

答案 0 :(得分:2)

SQL Fiddle

Oracle 11g R2架构设置

CREATE TABLE table_name ( json CLOB )
/

INSERT INTO table_name VALUES (
  '{"OBJECT ID":"71864756","OBJECT NAME":"MESSENGER","PARENT ID":"71865529","OBJECT STATUS":"O","WHITE LISTED":"N","LAST UPLOAD":"","PARENT CLASS":"ORDER","IS A LINK OBJECT IND":"N","AOL IM FEDERATION":"false","ATTRIBUTE 1":"0","ATTRIBUTE 2":"0","ATTRIBUTE 3":"0","ATTRIBUTE 4":"0","ATTRIBUTE 5":"0","CLASSIC CENTER INTEGRATION URL":"","COMMENTS":"","DISPLAY NAME":"","DOMAIN NAME LIST":"xyz.com","ICON NAME":"SERVICE_16.PNG","IM LICENSES":"500"}'
)
/

查询1

SELECT REGEXP_SUBSTR(
         json,
         '[{,]"DOMAIN NAME LIST":"((\\.|[^"])*)"',
         1,
         1,
         NULL,
         1
       ) AS domain_name_list
FROM   table_name

<强> Results

| DOMAIN_NAME_LIST |
|------------------|
|          xyz.com |