Python脚本收到错误的结果输出

时间:2019-07-16 16:21:22

标签: python

结果不输出。我收到错误消息,请帮忙。

有人可以告诉我这是怎么了吗?我刚刚开始编程。我可以运行脚本,但结果不显示。我收到错误消息,请帮忙。

enter link description here

DECLARE
@Columns as VARCHAR(MAX),
@SQL as VARCHAR(MAX)
SELECT @Columns =
COALESCE(@Columns + ', ','') + QUOTENAME(ColumnName)
FROM
   (select distinct (ColumnName)
        FROM vw_PZD_Detail_DLG_Data INNER JOIN
            vw_Base_Batch_Events ON vw_PZD_Detail_DLG_Data.ReferenceInteger = vw_Base_Batch_Events.ReferenceInteger
                    where (EventType IN ('NONCONF', 'REJECT', 'SKIP')) AND (MachineNumber LIKE '5999%') AND (LogDate BETWEEN CONVERT(DATETIME, '2019-06-01 00:00:00', 102) AND CONVERT(DATETIME, '2019-06-30 00:00:00', 102))) AS B
ORDER BY B.ColumnName

SET @SQL = 'SELECT HydraBatch, MESOrderNumber, MaterialNumberInputOrOutputBatch, ' + @Columns + '
FROM
(
select vw_Base_Batch_Events.MESOrderNumber, vw_Base_Batch_Events.HydraBatch,vw_Base_Batch_Events.MaterialNumberInputOrOutputBatch, vw_PZD_Detail_DLG_Data.Entry,vw_PZD_Detail_DLG_Data.ColumnName,vw_PZD_Detail_DLG_Data.ColumnValue
FROM            vw_PZD_Detail_DLG_Data INNER JOIN
                         vw_Base_Batch_Events ON vw_PZD_Detail_DLG_Data.ReferenceInteger = vw_Base_Batch_Events.ReferenceInteger
where (EventType IN ("NONCONF", "REJECT", "SKIP")) AND (MachineNumber LIKE "5999%") AND (LogDate BETWEEN CONVERT(DATETIME, "2019-06-01 00:00:00", 102) AND CONVERT(DATETIME, "2019-06-30 00:00:00", 102))
) as PivotData
PIVOT
(max(MESOrderNumber),Max(HydraBatch), Max(MaterialNumberInputOrOutputBatch)
FOR ColumnName in (' + @Columns + ')
) as PivotResult
ORDER BY MESOrderNumber, HydraBatch'

exec(@SQL);

感谢您的帮助。

LogCat

  

回溯(最近一次通话最近):文件“ rtrtemplate.py”,第33行,结果= src.substitute(d)文件“ C:\ Users \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ string “ .py”,第132行,以替代方式返回self.pattern.sub(convert,self.template)文件“ C:\ Users \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ string.py”,第129行,在转换self._invalid(mo)文件“ C:\ Users \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ string.py”,第105行,以_invalid(lineno,colno))

1 个答案:

答案 0 :(得分:0)

按照this指南进行操作。

确保模板格式正确,字典标签与模板占位符匹配。如果仍然存在,请发表评论。:)