apex_string.split 新行作为分隔符
我正在使用此查询来拆分 SQL 查询中文本区域字段的字符串:
select * from "MyTable" a
where NAME in (select * from
TABLE(apex_string.split(:P23_TEXTAREA, ',')))
它可以工作,但我想使用新行分隔符而不是逗号来拆分字符串。我已经尝试过“\n”、“\r\n”、“
”但没有成功。如果我删除分隔符并使用默认分隔符,则字符串仅用新行分割一次。如何用多个新行分隔的条目分割字符串?
I am using this query to split a string of a text area field inside my SQL query:
select * from "MyTable" a
where NAME in (select * from
TABLE(apex_string.split(:P23_TEXTAREA, ',')))
It works but I would like to split the string with a new line delimiter instead of a comma. I tried already "\n", "\r\n", "
" but without success. If I remove the delimiter and use the default, the string gets split only once with a new line. How can I split my string with multiple new line separated entries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用
CHR
函数:或包含换行符的字符串文字:
您的
:P23_TEXTAREA
值为:'TRI_1000'||CHR(13)||CHR (10)||'TRI_10'
,如果您将其拆分为CHR(10)
(LF),将为您提供值'TRI_1000'||CHR(13)
和'TRI_10'
以及第二个可能会匹配,但第一个由于尾随回车 (CR) 字符而不会匹配。看来您需要修剪结果或按 CR/LF (或可选的 CR)拆分,而不仅仅是 LF:
或:
You can try the
CHR
function:or a string literal containing a newline:
Your
:P23_TEXTAREA
value is:'TRI_1000'||CHR(13)||CHR(10)||'TRI_10'
which, if you split it onCHR(10)
(LF) will give you the values'TRI_1000'||CHR(13)
and'TRI_10'
and the second will probably match but the first will not due to the trailing carriage return (CR) character.It appears you need to either trim the result or split on CR/LF (or an optional CR) rather than just LF:
or:
apex_string.split
的默认分隔符是 LF(换行),因此一种方法是在将 CR+LF 组合传递给 split 之前将其替换为单个 LF:The default delimiter for
apex_string.split
is LF (line feed) so one way to do this is to replace the CR+LF combos with a single LF before passing it to split: