Home > database >  Oracle intercept string
Oracle intercept string

Time:09-28

From the table (v_table) interception field (error_note) of string "RspType push" in the first string [] KKKK and prompt,
XXXXXXX, KKKK and prompt the length is not fixed, how to capture? Consult everybody a great god, thank you,
The select error_note from v_table;
XXXXXXXXXXXXXXXX [KKKK_PPPP], "" RspType" XXXXXXXXXXXXXXXX
Small new hand,
thank you?

CodePudding user response:

Baidu regexp_substr

CodePudding user response:

You can use the substr function

CodePudding user response:

Regexp_substr on baidu checked, but still won't use, I is how food

CodePudding user response:

KKKK and prompt is separated with _?
If it is can use the
Select substr (error_note, INSTR (error_note, '[') + 1, INSTR (error_note,' _ ') - INSTR (error_note, '[') - 1) kk,
Substr (error_note, INSTR (error_note, '_') + 1, INSTR (error_note, '] ') - INSTR (error_note, '_') - 1) pp
The from v_table

CodePudding user response:

AS
 WITH T(SELECT the 'XXXXXXXXXXXXXXXX [KKKK_PPPP], "" RspType XXXXXXXXXXXXXXXX' S 
"The FROM DUAL
UNION ALL
SELECT '[XXX XXXX] XXXXXXXXX [KKKK_PPPP] ", "RspType XXXXXXXXXXXXXXXX' S
"The FROM DUAL
UNION ALL
SELECT 'XXXXXXXXXXXXXXXX [KKKK_PPPP], "asdfasdfa" RspType XXXXXXXXXXXXXXXX' S
"The FROM DUAL)
SELECT the S, S1, REGEXP_SUBSTR (S1, '[^ _] +', 1, 1) K,
REGEXP_SUBSTR (S1, '[^ _] +', 1, 2) P
The FROM (SELECT S REGEXP_REPLACE (S, '. * \ [(\ [^ \ [] +)]. * "RspType". * ', '\') 1 S1
The FROM T)

CodePudding user response:

reference 4 floor gaojiagang response:
KKKK and prompt is separated with _?
If it is can use the
Select substr (error_note, INSTR (error_note, '[') + 1, INSTR (error_note,' _ ') - INSTR (error_note, '[') - 1) kk,
Substr (error_note, INSTR (error_note, '_') + 1, INSTR (error_note, '] ') - INSTR (error_note, '_') - 1) pp
The from v_table


Thank you for the great god, today I just registered, the first post of hair, have so many kind people help, the heart, brother!

CodePudding user response:

reference 5 floor chengccy reply:
 WITH T AS 
(SELECT the 'XXXXXXXXXXXXXXXX [KKKK_PPPP], "" RspType XXXXXXXXXXXXXXXX' S
"The FROM DUAL
UNION ALL
SELECT '[XXX XXXX] XXXXXXXXX [KKKK_PPPP] ", "RspType XXXXXXXXXXXXXXXX' S
"The FROM DUAL
UNION ALL
SELECT 'XXXXXXXXXXXXXXXX [KKKK_PPPP], "asdfasdfa" RspType XXXXXXXXXXXXXXXX' S
"The FROM DUAL)
SELECT the S, S1, REGEXP_SUBSTR (S1, '[^ _] +', 1, 1) K,
REGEXP_SUBSTR (S1, '[^ _] +', 1, 2) P
The FROM (SELECT S REGEXP_REPLACE (S, '. * \ [(\ [^ \ [] +)]. * "RspType". * ', '\') 1 S1
The FROM T)


Thank you for the great god, today I just registered, the first post of hair, have so many kind people help, the heart, brother!
  • Related