regexp-substr

oracle get all matched occurrences from a column

强颜欢笑 提交于 2019-12-11 15:17:29
问题 I have a table, which has 2 columns: ID & JOB_Description(Text). I would like to write an oracle SQL to extract all substrings in the Description column which match a regular pattern. However, I have learnt how to extract matched substrings from a string with below SQL, but I have no idea to apply below SQL on all data in one go on the aforementioned table(column:JOB_Description). SQL to get all matched occurrences from a string: SELECT REGEXP_SUBSTR(JOB_Description, '(ABC|DE)([[:digit:]]){5}

splitting comma separated list into a temp table

本秂侑毒 提交于 2019-12-11 11:18:54
问题 I want to convert the following IN query into inner join query : select country, name, rank from table person_details where country in ('india','USA','australia') and name in ('tom', 'jill', 'jack') and rank in ('first', 'third', 'fifith'); I have two questions: this table is big so will changing this IN query into inner join will speed up things. What will be best way to split this comma separated list to a column in some temp table. I have see many regex examples but they seem too complex

Having issue with back reference in TCL

微笑、不失礼 提交于 2019-12-08 09:48:16
问题 I have the following code: set a "10.20.30.40" regsub -all {.([0-9]+).([0-9]+).} $a {\2 \1} b I am trying to grep 2nd and 3rd octet of the IP address. Expected output: 20 30 Actual output: 20 04 0 What is my mistake here? 回答1: You need to set the variables for the match and captured groups, then you can access them. Here is an example: set a "10.20.30.40" set rest [regexp {[0-9]+\.([0-9]+)\.([0-9]+)\.[0-9]+} $a match submatch1 submatch2] puts $submatch1 puts $submatch2 Output of the demo 20

Regular Expression for REGEXP_SUBSTR in Oracle

狂风中的少年 提交于 2019-12-06 09:21:44
I have the following text to search: #S7Z OK #Wed Feb 18 07:16:26 GMT 2015 expiration=10.0 lastModified=1424192425832 length=466472 path=/name/_master_/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf userType= The words proceeding each = are the names of properties. For each property name, I'd like to get the property value. That means I'm looking for a regular expression to use with regexp_substr to get the value of each known property. Something like this: SELECT REGEXP_SUBSTR( '#S7Z OK #Wed Feb 18 07:16:26 GMT 2015 expiration=10.0 lastModified=1424192425832 length=466472 path=/name/_master_

Oracle - get table name from sql text

廉价感情. 提交于 2019-12-01 08:50:11
I have a column in a table with simple sql queries and I want to regexp_substr the table name from them. Examples of texts: SELECT PT.PT_PARTY_NAME VALUE,PT.PT_PARTY_NAME LABEL FROM DWH_OWNER.DWH_ACCOUNTS ACC, DWH_OWNER.DWH_PARTIES PT WHERE ACC.ACC_SOURCE_ID = :P_DOMVAL_REF1 AND ACC.ACC_PT_KEY = PT.PT_KEY or SELECT DISTINCT QRMPT_PRODUCT VALUE, QRMPT_PRODUCT LABEL FROM DWH_OWNER.DWH_QRM_PRODUCT_TYPES ORDER BY VALUE So, I need to find the "FROM", skip some whitespaces then get the first word. I'm not interested for the moment in the second table. What I've done: select sql, regexp_substr(upper

Oracle - get table name from sql text

此生再无相见时 提交于 2019-12-01 06:42:21
问题 I have a column in a table with simple sql queries and I want to regexp_substr the table name from them. Examples of texts: SELECT PT.PT_PARTY_NAME VALUE,PT.PT_PARTY_NAME LABEL FROM DWH_OWNER.DWH_ACCOUNTS ACC, DWH_OWNER.DWH_PARTIES PT WHERE ACC.ACC_SOURCE_ID = :P_DOMVAL_REF1 AND ACC.ACC_PT_KEY = PT.PT_KEY or SELECT DISTINCT QRMPT_PRODUCT VALUE, QRMPT_PRODUCT LABEL FROM DWH_OWNER.DWH_QRM_PRODUCT_TYPES ORDER BY VALUE So, I need to find the "FROM", skip some whitespaces then get the first word.

Comparing comma separated values from two columns of two different tables

扶醉桌前 提交于 2019-11-29 23:44:08
问题 I want to compare the values of two columns (diff table) having comma separated values of two different Oracle tables. I want to find rows that match with all values ( NAME1 all values should match with NAME2 values). Note: The comma separated values are in different order. Example: T1: ID_T1 NAME1 =================================== 1 ASCORBIC ACID, PARACETAMOL, POTASSIUM HYDROGEN CARBONATE 2 SODIUM HYDROGEN CARBONATE, SODIUM CARBONATE ANHYDROUS, CITRIC ACID 3 CAFFEINE, PARACETAMOL PH. EUR.

Extract date from string oracle

有些话、适合烂在心里 提交于 2019-11-28 14:43:17
I have a column in which a string starts with - 'Chicago, IL, April 20, 2015 — and so on text here'. I want to extract the Date part from this string in Oracle. Any ideas on how to do this. I was able to find something for mm/dd/yyyy like below, but not for long date format. SELECT REGEXP_SUBSTR(' the meeting will be on 8/8/2008', '[0-9]{1,}/[0-9]{1,}/[0-9]{2,}') FROM dual If your columns value is always start with 'Chicago, IL, April 20, 2015 — and so on text here' then you could simly use SUBSTR instead of REGEXP_SUBSTR SELECT SUBSTR(column_name ,INSTR(column_name, ',', 1, 2) + 1 ,INSTR

Splitting comma separated values in Oracle

心不动则不痛 提交于 2019-11-28 11:48:33
I have column in my database where the values are coming like the following: 3862,3654,3828 In dummy column any no. of comma separated values can come. I tried with following query but it is creating duplicate results. select regexp_substr(dummy,'[^,]+',1,Level) as dummycol from (select * from dummy_table) connect by level <= length(REGEXP_REPLACE(dummy,'[^,]+'))+1 I am not understanding the problem. Can anyone can help? Lalit Kumar B Works perfectly for me - SQL> WITH dummy_table AS( 2 SELECT '3862,3654,3828' dummy FROM dual 3 ) 4 SELECT trim(regexp_substr(dummy,'[^,]+',1,Level)) AS dummycol

Splitting comma separated values in Oracle

回眸只為那壹抹淺笑 提交于 2019-11-27 19:21:29
问题 I have column in my database where the values are coming like the following: 3862,3654,3828 In dummy column any no. of comma separated values can come. I tried with following query but it is creating duplicate results. select regexp_substr(dummy,'[^,]+',1,Level) as dummycol from (select * from dummy_table) connect by level <= length(REGEXP_REPLACE(dummy,'[^,]+'))+1 I am not understanding the problem. Can anyone can help? 回答1: Works perfectly for me - SQL> WITH dummy_table AS( 2 SELECT '3862