Oracle12c,procedure where clause use REGEXP_SUBSTR

Hello everyone!
Oracle12c, procedure where clause need split input string by “,” and use the split result connect where clause.
For example:
Table ECOS_SYS_LOG’s column content,one of this column’s value(json format) is:

{  
  "FUN_ID": "010303",  
  "SysUserInfo": {  
    "SysUserName": "0001",  
    "SysUserCode": "US10901",  
    "SysId": "0001",  
    "DID": "TRE02200007",  
    "OrgCode": "BM220000",  
    "OrgName": "v1",  
    "ComName": "v2",  
    "Role": "10002375",  
    "Menu": "",  
    "ClientIp": "1",  
    "ServerIp": "1",  
    "SFA": "3AD32E36-66DE-40C6-B06E-ACB311E89A29",  
    "IsHide": "",  
    "ShowPrice": ""  
  } 

If input string is “010203,US10901,1174”.
I want to split the string “010203,US10901,1174” ,change to:

010203
US10901
1174

I want to query like this:

select * from ECOS_SYS_LOG T1 where T1.CONTENT like '%010203%' and T1.CONTENT like '%US10901%'  and T1.CONTENT like '%1174%' ORDER BY T1.TIME desc  

My procedure code is:

CREATE OR REPLACE   
PROCEDURE PR_ECOS_LOG_PRINT  (  
  V_IN_STR  IN  VARCHAR2, --The input string V_IN_STR is:010203,US10901,1174  
  V_OU_MSG  OUT VARCHAR2  
)  
IS  
  
  
BEGIN  
     V_OU_MSG := '';  
  begin  
  for rec in (select * from ECOS_SYS_LOG T1 where T1.CONTENT like '%010203%' and T1.CONTENT like '%US10901%'  and T1.CONTENT like '%1174%' ORDER BY T1.TIME desc)  
          --I want to split V_IN_STR make "010203,US10901,1174"to three value "010203" and "US10901" and "1174",use  three value  as previous line  
       loop   
  dbms_output.put_line('TIME:' || to_char(rec.TIME,'YYYY-MM-DD HH24:MI:SS') || ' , ' ||'CONTENT:' || rec.CONTENT  );     
  dbms_output.put_line('');  
  
  
       end loop;  
  V_OU_MSG := 'OK';  
  end;  
  RETURN;  
  
  
   EXCEPTION  
    WHEN OTHERS THEN  
    V_OU_MSG  := '{"ERROR":"reason is:'|| SQLERRM ||'"}';  
          
END PR_ECOS_LOG_PRINT;  

I know I can use “REGEXP_SUBSTR” to split the string :

SELECT REGEXP_SUBSTR('010203,US10901,1174', '[^,]+', 1, LEVEL, 'i')   
AS STR FROM DUAL CONNECT BY LEVEL <= LENGTH('010203,US10901,1174') - LENGTH(REGEXP_REPLACE('010203,US10901,1174', ',', '')) + 1;   

But after that ,what should I do to connect three value to where clause ?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.