Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/79.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 我试图理解这一串代码及其含义,特别是这';[^ |]和#x2B';_Sql_Oracle - Fatal编程技术网

Sql 我试图理解这一串代码及其含义,特别是这';[^ |]和#x2B';

Sql 我试图理解这一串代码及其含义,特别是这';[^ |]和#x2B';,sql,oracle,Sql,Oracle,我收到一封同事发来的电子邮件,询问谁已经不在公司了,我正试图理解它在说什么 , case when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0) then regexp_substr(c_qty, '[^|]+', 1, 1) - nvl(sum(cd.actl_qty),0) else null end Curr_Var , case when regexp_substr(c_qty, '[^|

我收到一封同事发来的电子邮件,询问谁已经不在公司了,我正试图理解它在说什么

, case when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0)
    then regexp_substr(c_qty, '[^|]+', 1, 1) - nvl(sum(cd.actl_qty),0) else null end Curr_Var
, case when regexp_substr(c_qty, '[^|]+', 1, 1) is null then 'First Count'
    when regexp_substr(c_qty, '[^|]+', 1, 1) = nvl(sum(cd.actl_qty),0)
        then 'Processed'
    when regexp_substr(c_qty, '[^|]+', 1, 1) > 0 and (regexp_substr(c_qty, '[^|]+', 1, 2) > 0 or regexp_substr(c_qty, '[^|]+', 1, 2) is null) and sum(cd.actl_qty) is null
        then 'Recount'
    when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0)
        and regexp_substr(c_qty, '[^|]+', 1, 1) = case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>1 then regexp_substr(c_qty, '[^|]+', 1, 2) else null end
        then 'Confirmed'
    when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0)
        and (regexp_substr(c_qty, '[^|]+', 1, 2) = nvl(sum(cd.actl_qty),0)
                or regexp_substr(c_qty, '[^|]+', 1, 3) = nvl(sum(cd.actl_qty),0)
                or regexp_substr(c_qty, '[^|]+', 1, 4) = nvl(sum(cd.actl_qty),0)
                or regexp_substr(c_qty, '[^|]+', 1, 5) = nvl(sum(cd.actl_qty),0)
                or regexp_substr(c_qty, '[^|]+', 1, 6) = nvl(sum(cd.actl_qty),0))
        then 'Expire Recent'
    when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0)
        and case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>1 then regexp_substr(c_qty, '[^|]+', 1, 2) else null end is null
        then 'Recount'
    when regexp_substr(c_qty, '[^|]+', 1, 1) <> nvl(sum(cd.actl_qty),0)
        and regexp_substr(c_qty, '[^|]+', 1, 1) <> case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>1
        then regexp_substr(c_qty, '[^|]+', 1, 2) else null end then 'Recount' else null end Directive
, regexp_substr(c_qty, '[^|]+', 1, 1) as Last_Cnt
, case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>1 then regexp_substr(c_qty, '[^|]+', 1, 2) else null end as Prev_Cnt1
, case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>2 then regexp_substr(c_qty, '[^|]+', 1, 3) else null end as Prev_Cnt2
, case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>3 then regexp_substr(c_qty, '[^|]+', 1, 4) else null end as Prev_Cnt3
, case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>4 then regexp_substr(c_qty, '[^|]+', 1, 5) else null end as Prev_Cnt4
, case when LENGTH(c_qty)-LENGTH(REPLACE(c_qty,'|',''))>5 then regexp_substr(c_qty, '[^|]+', 1, 6) else null end as Prev_Cnt5
,regexp_substr(c|u数量,[^ |]+',1,1)nvl(总和(cd.actl|u数量),0)时的大小写
然后regexp_substr(c_数量,[^ |]+',1,1)-nvl(sum(cd.actl_数量),0)否则为空结束货币变量
,当regexp_substr(c_数量,[^ |]+',1,1)为空时,则为“第一次计数”
当regexp_substr(c_数量,[^ |]+',1,1)=nvl(总和(cd.actl_数量),0)
然后“处理”
当regexp_substr(c_数量,[^ |]+',1,1)>0和(regexp_substr(c_数量,[^ |]+',1,2)>0或regexp_substr(c_数量,[^ |]+',1,2)为空时,和(cd.actl_数量)为空
然后“重新计票”
当regexp_substr(c_数量,[^ |]+',1,1)nvl(总和(cd.actl_数量),0)
和regexp_substr(c_数量,[^ |]+',1,1)=当长度(c_数量)-LENGTH(替换(c_数量,[^ |','')大于1时,则regexp_substr(c|数量,[^ |]+',1,2)否则为空
然后“确认”
当regexp_substr(c_数量,[^ |]+',1,1)nvl(总和(cd.actl_数量),0)
和(regexp_substr(c_数量,[^ |]+',1,2)=nvl(总和(cd.actl_数量),0)
或regexp_substr(c_数量,[^ |]+',1,3)=nvl(总和(cd.actl_数量),0)
或regexp_substr(c_数量,[^ |]+',1,4)=nvl(总和(cd.actl_数量),0)
或regexp_substr(c_数量,[^ |]+',1,5)=nvl(总和(cd.actl_数量),0)
或regexp_substr(c_数量,[^ |]+',1,6)=nvl(总和(cd.actl_数量),0))
然后“最近到期”
当regexp_substr(c_数量,[^ |]+',1,1)nvl(总和(cd.actl_数量),0)
当长度(c|qty)-LENGTH(REPLACE(c|qty,“,”)>1时,则regexp|u substr(c|qty,[^ |]+',1,2)否则null end为null
然后“重新计票”
当regexp_substr(c_数量,[^ |]+',1,1)nvl(总和(cd.actl_数量),0)
和regexp_substr(c|u数量,[^ |]+',1,1)当长度(c|u数量)-长度(替换(c|u数量,'.''','')大于1时的情况
然后是regexp_substr(c_数量,[^ |]+',1,2)else空结束,然后是“重新计数”else空结束指令
,regexp_substr(c_数量,[^ |]+',1,1)作为最后一个
,当长度(c|qty)-LENGTH(替换(c|qty,“,”)>1,然后将regexp|u substr(c|qty,[^ |]+',1,2)作为上一个Cnt1结束,否则为空
,当长度(c|qty)-LENGTH(替换(c|qty,“,”)>2,然后将regexp|u substr(c|qty,[^ |]+',1,3)作为上一个Cnt2结尾,否则为空
,当长度(c|qty)-LENGTH(替换(c|qty,“,”)>3时,则为regexp|u substr(c|qty,[^ |]+',1,4),否则为空,作为上一个Cnt3结束
,当长度(c|qty)-LENGTH(替换(c|qty,“,”)>4,然后将regexp|u substr(c|qty,[^ |]+',1,5)设置为空,否则作为上一个Cnt4结束
,当长度(c|qty)-LENGTH(替换(c|qty,“,”)>5时,则为regexp|u substr(c|qty,[^ |]+',1,6),否则为空,作为上一个Cnt5结束
我试图研究这些语句,但运气不佳,请有人给我解释一下,谢谢。

regexp\u substr()
函数用于基于正则表达式提取子字符串

[^ |]+
是一个正则表达式,表示不包含垂直条的字符串

regexp_substr(c_数量,[^ |]+',1,1)
返回字符串的第一个匹配项,该字符串不包含从字符串的第一个字符开始的
c_数量
列中的垂直条

此模式通常用于从管道分隔列表中提取项目。例如,
REGEXP_SUBSTR('A | B','[^ |]+',1,1)
返回
A
REGEXP_SUBSTR('A | B','[^ |]+',1,2)
返回
B
,等等。这类代码通常意味着数据模型存在问题;看起来有人在将非关系数据插入关系数据库。如果每一列只包含原子数据类型,查询就会更容易。额外的连接比解析列表容易得多

更多信息