Можете да използвате regexp_substr
за да разделите входните си данни на редове и след това да потърсите съответните низове, например:
SQL> SELECT regexp_substr(line, 'aXYZApple[^,]*') subtxt
2 FROM (SELECT regexp_substr(:x, '[^|]*\|', 1, rownum + 1) line
3 FROM dual
4 CONNECT BY LEVEL <= length(:x) - length(REPLACE(:x, '|', '')))
5 WHERE regexp_substr(line || ',', '[^,]*,', 1, 2) = 'OU=Managed,'
6 AND line LIKE '%aXYZApple%';
SUBTXT
--------------------------------------------------------------------------------
aXYZApple-Au
aXYZApple-Readonly
aXYZApple-Write
Ето малко пояснение. Трябва да преминете през заявката стъпка по стъпка.
Вътрешната част на заявката ще премине през вашите данни (за всеки |
):
SQL> SELECT regexp_substr(:x, '[^|]*\|', 1, rownum + 1) line
2 FROM dual
3 CONNECT BY LEVEL <= length(:x) - length(REPLACE(:x, '|', ''));
LINE
--------------------------------------------------------------------------------
CN=aXYZApple-Au,OU=Managed,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
CN=31107427,OU=Distribution Lists,OU=Shared Mailboxes,DC=core,DC=dir,DC=abc,DC=
CN=ea90045052,OU=Groups,OU=eProfile,DC=core,DC=dir,DC=abc,DC=com |
CN=S0901448,OU=Distribution Lists,OU=Shared Mailboxes,DC=core,DC=dir,DC=abc,DC=
CN=00900887,OU=Distribution Lists,OU=Shared Mailboxes,DC=core,DC=dir,DC=abc,DC=
CN=NSMMMM,OU=LRP,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
CN=aXYZApple-Readonly,OU=Managed,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
CN=WWSWW-Au,OU=LRP,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
CN=aLogical_RW,OU=Managed,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
CN=aXYZApple-Write,OU=Managed,OU=Groups,DC=core,DC=dir,DC=abc,DC=com |
След това ще извършите цикъл за OU=Managed
низ на втората позиция:
SQL> SELECT regexp_substr(line || ',', '[^,]*,', 1, 2) second_part
2 FROM (SELECT regexp_substr(:x, '[^|]*\|', 1, rownum + 1) line
3 FROM dual
4 CONNECT BY LEVEL <= length(:x) - length(REPLACE(:x, '|', '')));
SECOND_PART
--------------------------------------------------------------------------------
OU=Managed,
OU=Distribution Lists,
OU=Groups,
OU=Distribution Lists,
OU=Distribution Lists,
OU=LRP,
OU=Managed,
OU=LRP,
OU=Managed,
OU=Managed,
Накрая изберете съответната част с последен regexp_substr
.