|
楼主 |
发表于 2013-10-17 14:58:08
|
显示全部楼层
本帖最后由 darbell 于 2013-10-17 15:00 编辑
用数据库跟踪执行的结果,上面为正常sql句,下面为异常(表上颜色处为对比异常,sql句少了一截,为啥?软件问题?):
select '' as SELCOL,(PP_POMain.MainID) as MainID,(PP_POMain.cInvCode) as cInvCode,(Inventory.cInvName) as cInvName,(computationUnit.cComUnitName) as cComUnitName,(Inventory.cInvStd) as cInvStd,(Inventory.cComUnitCode) as cComUnitCode,(isnull(PP_POMain.fQuantity,0)) as fQuantity,(isnull(PP_POMain.fInquantity,0)) as fInquantity,(isnull(CUR.iCurQuantity,0)) as iCurQuantity,(PP_POMain.dStartDate) as dStartDate,(PP_POMain.dEndDate) as dEndDate,(PP_POMain.citemName) as citemname,(PP_POMain.citemcode) as citemcode,(fitem.cItem_Name) as citem_name,(PP_POMain.citem_Class) as citem_Class,(Inventory.cinvaddcode) as cinvaddcode,(PmSocode.csocode) as csocode,(pp_pomain.cmemo) as cmemo,(pp_pomain.cclose) as cclose,(isnull(pp_pomain.cbomsocode, '' )) as cbomsocode,(isnull(pp_pomain.fbhgquantity,0)) as fbhgquantity,(isnull(pp_pomain.fhgquantity,0)) as fhgquantity,(isnull(pp_pomain.fquantityed,0)) as fquantityed,(isnull(pp_pomain.fnum,0)) as fnum,(isnull(pp_pomain.finnum,0)) as finnum,(PP_POMain.cbatch) as cpobatch,((case when inventory.igrouptype = 1 then computationunit2.ichangrate else (case when inventory.igrouptype = 0 then null else (case when (pp_pomain.fnum = 0 or pp_pomain.fnum is null) or (pp_pomain.fquantity = 0 or pp_pomain.fquantity is null) then null else pp_pomain.fquantity / pp_pomain.fnum end) end) end) ) as iinvexchrate from PP_POMain left join ( select pp_pomain.mainid, so_sodetails.csocode from ( select * from pp_pomain where len(csosids)-len(replace(csosids,',',''))<=2 ) pp_pomain left join so_sodetails on pp_pomain.csosids = ',' + cast(so_sodetails.isosid as varchar(50)) + ',' union select pp_pomain.mainid, so_sodetails.csocode from ( select * from pp_pomain where len(csosids)-len(replace(csosids,',',''))>2 ) pp_pomain left join so_sodetails on pp_pomain.csosids like '%,' + cast(so_sodetails.isosid as varchar(50)) + ',%' ) PmSocode on PmSocode.mainid = pp_pomain.mainid left join rdrecords on pp_pomain.irdautoid=rdrecords.autoid left join rdrecord on rdrecords.id=rdrecord.id left join computationunit as computationunit2 on pp_pomain.cunitid = computationunit2.ccomunitcode inner join PP_ProductPO ON PP_POMain.ID=PP_ProductPO.ID LEFT OUTER JOIN (SELECT '' AS iCurQuantity,MAINID FROM PP_POMain) CUR ON CUR.MAINID = PP_POMain.MAINID LEFT OUTER JOIN Inventory ON Inventory.cInvCode = PP_POMain.cInvCode LEFT OUTER JOIN computationUnit ON Inventory.cComUnitCode = computationUnit.cComunitCode left join fitem on pp_pomain.citem_class = fitem.citem_class where (PP_POMain.id in (27) and PP_POMain.bUsed=0 and exists(select * from PP_PODetails where PP_PODetails.MainID=PP_POMain.MainID) and PP_POMain.ID in (select ID from PP_ProductPO where iState=2) ) and PP_POMain.mainid in (select mainid from pp_podetails where isnull(fquantity,0)>isnull(foutquantity,0) or isnull(fnum,0)>isnull(foutnum,0)) and (PP_POMain.cclose='' or PP_POMain.cclose is null)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select '' as SELCOL,(PP_POMain.MainID) as MainID,(PP_POMain.cInvCode) as cInvCode,(Inventory.cInvName) as cInvName,(computationUnit.cComUnitName) as cComUnitName,(Inventory.cInvStd) as cInvStd,(Inventory.cComUnitCode) as cComUnitCode,(isnull(PP_POMain.fQuantity,0)) as fQuantity,(isnull(PP_POMain.fInquantity,0)) as fInquantity,(isnull(CUR.iCurQuantity,0)) as
iCurQuantity,(PP_POMain.dStartDate) as dStartDate,(PP_POMain.dEndDate) as dEndDate,(PP_POMain.citemName) as citemname,(PP_POMain.citemcode) as citemcode,(fitem.cItem_Name) as
citem_name,(PP_POMain.citem_Class) as citem_Class,(Inventory.cinvaddcode) as cinvaddcode,(PmSocode.csocode) as csocode,(pp_pomain.cmemo) as cmemo,(pp_pomain.cclose) as cclose,(isnull(pp_pomain.cbomsocode, ''
)) as cbomsocode,(isnull(pp_pomain.fbhgquantity,0)) as fbhgquantity,(isnull(pp_pomain.fhgquantity,0)) as fhgquantity,(isnull(pp_pomain.fquantityed,0)) as fquantityed,(isnull(pp_pomain.fnum,0)) as fnum,(isnull(pp_pomain.finnum,0)) as finnum,(PP_POMain.cbatch) as cpobatch,((case when inventory.igrouptype = 1 then computati) as iinvexchrate from PP_POMain left join ( select pp_pomain.mainid, so_sodetails.csocode from ( select * from pp_pomain where len(csosids)-len(replace(csosids,',',''))<=2 ) pp_pomain left join so_sodetails on pp_pomain.csosids = ',' + cast(so_sodetails.isosid as varchar(50)) + ',' union select pp_pomain.mainid, so_sodetails.csocode from ( select * from pp_pomain where len(csosids)-len(replace(csosids,',',''))>2 ) pp_pomain left join so_sodetails on pp_pomain.csosids like '%,' + cast(so_sodetails.isosid as varchar(50)) + ',%' ) PmSocode on PmSocode.mainid = pp_pomain.mainid left join rdrecords on pp_pomain.irdautoid=rdrecords.autoid left join rdrecord on rdrecords.id=rdrecord.id left join computationunit as computationunit2 on pp_pomain.cunitid = computationunit2.ccomunitcode inner join PP_ProductPO ON PP_POMain.ID=PP_ProductPO.ID LEFT OUTER JOIN (SELECT '' AS iCurQuantity,MAINID FROM PP_POMain) CUR ON CUR.MAINID = PP_POMain.MAINID LEFT OUTER JOIN Inventory ON Inventory.cInvCode = PP_POMain.cInvCode LEFT OUTER JOIN computationUnit ON Inventory.cComUnitCode = computationUnit.cComunitCode left join fitem on pp_pomain.citem_class = fitem.citem_class where (PP_POMain.id in (3) and PP_POMain.bUsed=0 and exists(select * from PP_PODetails where PP_PODetails.MainID=PP_POMain.MainID) and PP_POMain.ID in (select ID from PP_ProductPO where iState=2) ) and PP_POMain.mainid in (select mainid from pp_podetails where isnull(fquantity,0)>isnull(foutquantity,0) or isnull(fnum,0)>isnull(foutnum,0)) and (PP_POMain.cclose='' or PP_POMain.cclose is null) |
|