-5

我想从 Taskdescription 选项卡中获取 URL,并在名称为 URL 的其他列中获取它。现在我正在使用这段代码

select 
     c.StreamName AS Category,
     ProcessInstanceAppianID as jobId,
     a.ProcessInstanceName,
     a.ProcessInstanceTargetDate AS TargetDate,
     a.ProcessInstanceDescription as TaskDescription,
     b.Name as department,
     SUBSTRING(ProcessInstanceName, NULLIF(PATINDEX('%[0-9][0-9][0-9][0-9][0-9]%',ProcessInstanceName),0),7) as code
from InternalUseOnly..ProcessInstance a 
          join InternalUseOnly..Departments b on 
                          b.KeyDepartment = a.KeyDepartmentEntered 
                      AND b.updoperation < 2
           join InternalUseOnly..ProcessStream c on 
                          c.KeyProcessStream = a.KeyProcessStream 
                      and c.updoperation < 2
where ProcessInstanceCompleted is null
      and a.KeyProcessStream in (330) 
      and a.updoperation <2

在此处输入图像描述

提前致谢

4

1 回答 1

3

如果您使用的是 SQL Server,那么这可以解决问题

SELECT substring(ProcessInstanceDescription , charindex('http://', ProcessInstanceDescription ), charindex('KeyInstr', ProcessInstanceDescription ) - charindex('http://', ProcessInstanceDescription ))
FROM InternalUseOnly..ProcessInstance;

这是一个SQLFiddle

就说我今天心情不错,这里有你需要的代码。URL 将位于第一列。

select
     substring(a.ProcessInstanceDescription , charindex('http://', a.ProcessInstanceDescription ), charindex('KeyInstr', a.ProcessInstanceDescription ) - charindex('http://', a.ProcessInstanceDescription )), 
     c.StreamName AS Category,
     ProcessInstanceAppianID as jobId,
     a.ProcessInstanceName,
     a.ProcessInstanceTargetDate AS TargetDate,
     a.ProcessInstanceDescription as TaskDescription,
     b.Name as department,
     SUBSTRING(ProcessInstanceName, NULLIF(PATINDEX('%[0-9][0-9][0-9][0-9][0-9]%',ProcessInstanceName),0),7) as code
from InternalUseOnly..ProcessInstance a 
          join InternalUseOnly..Departments b on 
                          b.KeyDepartment = a.KeyDepartmentEntered 
                      AND b.updoperation < 2
           join InternalUseOnly..ProcessStream c on 
                          c.KeyProcessStream = a.KeyProcessStream 
                      and c.updoperation < 2
where ProcessInstanceCompleted is null
      and a.KeyProcessStream in (330) 
      and a.updoperation <2

更新:

关于Invalid length parameter passed to the LEFT or SUBSTRING function.错误,这意味着您在ProcessInstanceDescription列中的某个位置,一行不适合 my SUBSTRING().

祝你好运,因为这是另一个问题,我不会给你解决方案,首先是因为信息不足,你不合作,显然不愿意自己做一些努力。

于 2013-07-16T07:29:52.657 回答