Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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 REGEXP\u SUBSTR转换的输出未强制转换为整数_Sql_Regex_Casting_Integer_Amazon Redshift - Fatal编程技术网

Sql REGEXP\u SUBSTR转换的输出未强制转换为整数

Sql REGEXP\u SUBSTR转换的输出未强制转换为整数,sql,regex,casting,integer,amazon-redshift,Sql,Regex,Casting,Integer,Amazon Redshift,我尝试使用下面的REGEXP\u SUBSTR Sql函数从20个字符的字符串中提取所有数字 select REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 1) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 2) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 3) ... ... || REGEXP_SUBSTR(substr

我尝试使用下面的REGEXP\u SUBSTR Sql函数从20个字符的字符串中提取所有数字

select
REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 1)
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 2)
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 3)
...
...
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 20)
from tbl;
但当尝试将其转换为bigint/decimal或任何数字数据类型时,由于类型numeric的
输入语法无效,或
无效数字,值“2”,位置0,类型:Long
等等


我错过什么了吗?REGEXP_SUBSTR串联的典型输出为1056220044022等。在红移数据仓库上运行的查询和REGEXP_REPLACE/TRANSLATE尚不存在。

看起来每当字符串中没有数字时,上述REGEXP_SUBSTR串联将返回空字符串(“”)不支持将其强制转换为整数。所以我使用了
NULLIF(regex表达式“”)