Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 甲骨文:分割字符串_Sql_Oracle_Split - Fatal编程技术网

Sql 甲骨文:分割字符串

Sql 甲骨文:分割字符串,sql,oracle,split,Sql,Oracle,Split,我有这样一个存储过程: ... IS l_count binary_integer; l_array dbms_utility.lname_array; BEGIN ... dbms_utility.comma_to_table ( list => regexp_replace(l_input,'(^|,)','\1x') , tablen => l_count , tab => l_array ); for i in 1 .. l_count

我有这样一个存储过程:

...
IS
l_count binary_integer;
l_array dbms_utility.lname_array;
BEGIN

...

dbms_utility.comma_to_table
  ( list   => regexp_replace(l_input,'(^|,)','\1x')
  , tablen => l_count
  , tab    => l_array
 );

for i in 1 .. l_count
     loop
        myQuery := myQuery || '''' || substr(l_array(i ),2) || '''';
        if i < l_count then
             myQuery := myQuery || ',';
       end if;
     end loop;
...
END;
。。。
是
l_计数二进制_整数;
l_数组dbms_utility.lname_数组;
开始
...
dbms_utility.逗号_to_表
(列表=>regexp_替换(l_输入,“(^ |,)”,“\1x”)
,tablen=>l_计数
,tab=>l_数组
);
因为我在1。。l_计数
环
myQuery:=myQuery | |“”| | substr(l_数组(i),2)| |“”;
如果我不算的话
myQuery:=myQuery | |',';
如果结束;
端环;
...
结束;
当我提交一个像“aaa,bbb,ccc”这样的字符串时,它可以很好地工作,但由于斜杠字符的缘故,不能与这个字符串“aaa,bb/b,ccc”一起工作


这个问题有解决办法吗?或者另一种方法?

使用
REPLACE
功能

''' || REPLACE('aaa,bb/b,ccc', ',','' '') || ''';
输出:

'aaa' 'bb/b' 'ccc'
e、 g


可以使用替换函数删除“/”字符。请参阅我不想替换此字符。因为我需要整个单词(bb/b)。因此,拆分的结果将是:“aaa”“bb/b”“ccc”您希望输出为“aaa”“bb/b”“ccc”还是“aaa”“bb/b”“ccc”“ccc”“更新为“aaa”“bb/b”“ccc”output@kkung您看到标记为重复的主题了吗?提供了多个选项以实现所需的输出。我尝试了它,但它无法解决我的斜杠字符问题。另外,我需要遍历字符串以逐个获取值。
''' || REPLACE(@string, ',','' '') || ''';