これ--
は、がセパレーターの一部で-->
あるが、セパレーターの一部ではないため->
です。
データ値に-->
このクエリが含まれている場合でも、エラーは発生しません。以下のように。
SQL> select Sys_Connect_By_Path('SomeText B-->More Text' || ':' || 'SomeText A-->More Text', ' --> ') "myNewVar"
from dual
connect by rownum<=3;
myNewVar
----------------------------------------------------
--> SomeText B-->More Text:SomeText A-->More Text
--> SomeText B-->More Text:SomeText A-->More Text --> SomeText B-->More Text:SomeText A-->More Text
--> SomeText B-->More Text:SomeText A-->More Text --> SomeText B-->More Text:SomeText A-->More Text --> SomeText B-->More Text:SomeText A-->More Text
上記の区切り文字は-->
、空白に注意してください。この空白は、区切り文字の一部と見なされchr(1)||chr(45)||chr(45)||chr(62)||chr(1)
ます。この文字列全体は、データまたは列の値の一部ではありません。
以下のようにエラーが発生します
SQL> select Sys_Connect_By_Path('SomeText B-->More Text' || ':' || 'SomeText A-->More Text', '-->') "myNewVar"
from dual
connect by rownum<=3;
ORA-30004: when using SYS_CONNECT_BY_PATH function, cannot have seperator as part of column value
30004. 00000 - "when using SYS_CONNECT_BY_PATH function, cannot have seperator as part of column value"
*Cause:
*Action: Use another seperator which does not occur in any column value,
then retry.
上記の区切り文字はです。-->
空白がないことに注意してchr(45)||chr(45)||chr(62)
ください。この文字列全体は、実際にはデータまたは列の値の一部であるため、エラーになります。
そして、ここに解決策があります(パフォーマンスはテストされていません)
select regexp_replace(Sys_Connect_By_Path('SomeText B-->More Text' || ':' || 'SomeText A-->More Text', ' -> '),' -> ','-->') "myNewVar"
from dual
connect by rownum<=3;
myNewVar
--------------------------------------
-->SomeText B-->More Text:SomeText A-->More Text
-->SomeText B-->More Text:SomeText A-->More Text-->SomeText B-->More Text:SomeText A-->More Text
-->SomeText B-->More Text:SomeText A-->More Text-->SomeText B-->More Text:SomeText A-->More Text-->SomeText B-->More Text:SomeText A-->More Text
説明-ここ(上記のクエリ)->
(スペースあり)は、ここのデータの一部ではありません-->
。列がパスによって接続されると、regexp_replace
すべての出現箇所がに置き換え->
られる-->
ため、この方法でも-->
、の代わりにセパレータとして使用できます->
。