Solved

Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.

Posted on 2015-01-11
2
109 Views
Last Modified: 2015-01-11
I am trying to run this code on MSSQL 2008  and get an error "Cursorfetch: The number of variables declared in the INTO list must match that of selected columns."
I counted the fields and variables several times..what am I doing wrong?


                   
	BEGIN

DECLARE	
 
@MainPN nvarchar(200),
@OpenSelect As nvarchar(500),
@TSQL nvarchar(4000) ,
@EVENTSTATUSH nvarchar(20),
@HDPROD   	nvarchar(200),      
@HDORMG	NUMERIC(5,2),
@HDRVMG	NUMERIC(5,2),
@HDORPL	NUMERIC(5,2),
@HDRVPL	NUMERIC(5,2),
@HDNOCL    	INT,
@HDNOPL    	INT,
@HDOUTP    	nvarchar(200),
@HDNOTH    	INT,
@HDOVSP    	NUMERIC(3,2),
@HDOVSN    	NUMERIC(2,1),
@HDSLDR    	nvarchar(200),
@HDSDCS    	nvarchar(200),
@HDSDPS    	nvarchar(200),
@HDMKCS    	nvarchar(200),
@HDMKPS    	nvarchar(200),
@HDCOLR    	nvarchar(200),
@HDHAL     	nvarchar(200),
@HDTKNA    	nvarchar(200),
@HDKUPN    	nvarchar(200),
@HDHMRG    	NUMERIC(3,2),
@HDSMZR    	nvarchar(200),
@HDOVMZ    	NUMERIC(3,1),
@HDSIBD    	nvarchar(200),
@HDHTML    	nvarchar(200),
@HDNAME    	nvarchar(200),
@HDTBDT    	nvarchar(200),
@HDOVS1    	NUMERIC(3,1),
@HDOVS2    	NUMERIC(3,1),
@HDCTMH    	nvarchar(200),
@HDCOC     	nvarchar(200),
@HDSHMG    		NUMERIC(5,2),
@HDSHPL    		NUMERIC(5,2),
@HDSPKG    	nvarchar(200),
@HDULRF    	nvarchar(200),
@HDSRTT    	nvarchar(200),
@HDMZHV    		NUMERIC(5,4),
@HDTKNZ    	nvarchar(200),
@HDCLRP    	nvarchar(200),
@HDCLRC    	nvarchar(200),
@HDCLRH    	nvarchar(200),
@HDGMKR    	nvarchar(200),
@HDBNMG    	nvarchar(200),
@HDFLKD    	nvarchar(200),
@HDDRKD    	nvarchar(200),
@HDDRMC    	nvarchar(200),
@HDMSMP    		NUMERIC(3,0),
@HDSHPD    		NUMERIC(5,2),
@HDSGHGTOP   	nvarchar(200),
@HDSGHGBOT    	nvarchar(200),
--@HDSGHG    	nvarchar(200),
@HDCATG    	  nvarchar(200),
@HDCAT1    	nvarchar(200),
@HDCAT2    	nvarchar(200),
@HDCAT3    	nvarchar(200),
@HDCAT4    	nvarchar(200),
@HDCLS3    	nvarchar(200),
@HDDHML    	nvarchar(200),
@HDMINC    	NUMERIC(4,3),
@HDSPBC    	NUMERIC(4,3),
@HDEXCT    	nvarchar(200),
@HDROZV    	NUMERIC(4,2),
@HDORZV    	NUMERIC(4,2),
@HDKUPP    	nvarchar(200),
@HDHTMP    	nvarchar(200),
@HDB40V    	nvarchar(200),
@HDKID2    	nvarchar(200),
@HDZKHS    	nvarchar(200),
@HDZPAZ    	nvarchar(200),
@HDASBO    	nvarchar(200),
@HDPMAG    	nvarchar(200),
@HDKRTS    	nvarchar(200),
@HDBOLA    	nvarchar(200),
@HDBOA     	nvarchar(200),
@HDAKPN    	nvarchar(200),
@HDOVNK    	NUMERIC(2,1),
@HDHAM     	nvarchar(200),
@HDMMAX    	NUMERIC(5,4),
@HDMMIN    	NUMERIC(5,4),
@HDMMET    	NUMERIC(5,4),
@HDKMAX    	NUMERIC(5,4),
@HDKMIN   	NUMERIC(5,4),
@HDKNOM    	NUMERIC(5,4),
@HDOVCU    	nvarchar(200),
@HDOVHG    	nvarchar(200),
@HDPEP     	nvarchar(200),
@HDSTAT    	INT,
@HDFLD21	nvarchar(200),
@HDFLD22	nvarchar(200),
@HDFLD23	nvarchar(200),
@HDFLD24	nvarchar(200),
@HDFLD25	nvarchar(200),
@HDLST     	INT,
@HDUSR     	nvarchar(200),
@HDWSID    	nvarchar(200),
@HDHSLC    	nvarchar(200),
@HDHATM    	nvarchar(200),
@HDHINS    	nvarchar(200),
@HDHHOL    	nvarchar(200),
@HDHADR    	nvarchar(200),
@HDH1SP    	nvarchar(200),
@HDH1TP    	nvarchar(200),
@HDH1CL    	nvarchar(200),
@HDH1CR    	nvarchar(200),
@HDH2SP    	nvarchar(200),
@HDH2TP    	nvarchar(200),
@HDH2CL    	nvarchar(200),
@HDH2CR    	nvarchar(200)
        
DECLARE cur_update_itemH CURSOR FOR  

select DISTINCT
EventStatus,
isnull(CPRT.ToolNum	,''),	
isnull(	PartData.BoardLength	,0	),
isnull(	PartData.BoardWidth	,0	),
isnull(	PartData.PanelLength	,0	),
isnull(	PartData.PanelWidth	,0	),
isnull(	PartData.LayerTo	,0	) LayerTo,
isnull(	UDFTool.ProdLayers	,0	)ProdLayers,
isnull(	UDFTool.OutsideLayers	,''	)OutsideLayers,
isnull(	UDFTool.GoldFinNum	,0	)GoldFinNum,
isnull(	PartData.FinThickNom	,0	)FinThickNom,
isnull(	PartData.GoldThick	,0	)GoldThick,
isnull(	SUBSTRING(UDFTool.SolderType,1,1),''	)SolderType,
isnull(	UDFTool.SolderCS	,''	)SolderCS,
isnull(	UDFTool.SolderPS	,''	)SolderPS,
isnull(	UDFTool.MarkingCS	,''	)MarkingCS,
isnull(	UDFTool.MarkingPS	,''	)MarkingPS,
isnull(	SUBSTRING(PartData.LegType,1,1)	,''	)LegType,
isnull(	UDFTool.HAL	,''	)HAL,
isnull(	UDFTool.CivilStandard	,''	)CivilStandard,
isnull(	UDFTool.SampleCoupon	,''	)SampleCoupon,
isnull(	UDFTool.SpecRMTick	,0	)SpecRMTick,
isnull(	UDFTool.HSType	,''	)HSType,
isnull(	UDFTool.HSTick	,0	)HSTick,
isnull(	SUBSTRING(UDFTool.HSProcess	,1,1)	,''	)HSProcess,
isnull(	UDFTool.SampleCroSec	,''	)SampleCroSec,
isnull(	UDFTool.Engineer	,''	)Engineer,
isnull(	UDFTool.DateCode	,''	)DateCode,
isnull(	UDFTool.MinCuSecondCoat	,0	)MinCuSecondCoat,
isnull(	UDFTool.MinTinLead	,0	)MinTinLead,
isnull(	UDFTool.HSMarking	,''	)HSMarking,
isnull(	UDFTool.COCReq	,''	)COCReq,
isnull(	UDFTool.PCBAreaDm2	,0	)PCBAreaDm2,
isnull(	UDFTool.PanelAreaIn2	,0	)PanelAreaIn2,
isnull(	UDFTool.PackingSpec	,''	)PackingSpec,
isnull(	UDFTool.ULRefReq	,''	)ULRefReq,
isnull( SUBSTRING(UDFTool.DrawNum,1,10)	,''	)DrawNum,
isnull(	UDFTool.GoldW	,0	)GoldW,
isnull(	UDFTool.MilitaryStandard	,''	)MilitaryStandard,
isnull( SUBSTRING(	UDFTool.MarkingColPS,1,1)	,''	)MarkingColPS,
isnull(	SUBSTRING(  UDFTool.MarkingColCS,1,1)	,''	)MarkingColCS,
isnull(	SUBSTRING(	UDFTool.MarkingColHS,1,1)	,''	)MarkingColHS,
isnull(	UDFTool.OriginalFilms	,''	)OriginalFilms,
isnull(	UDFTool.MagneticDB	,''	)MagneticDB,
isnull(	UDFTool.DielectricDistanceReq	,''	)DielectricDistanceReq,
isnull(	UDFTool.MechanicalDrillLayout	,''	)MechanicalDrillLayout,
isnull(	UDFTool.XYCutsReq	,''	)XYCutsReq,
isnull(	PartData.PanelUP	,0	)PanelUP,
isnull(	UDFTool.PanelAreaDm2	,0	)PanelAreaDm2,
CASE WHEN UDFTool.StrCupTopMic=1  THEN isnull(cast(PartData.CuAreaTop as nvarchar(40)),'') +  CHAR(181) + ' / '  ELSE isnull(cast(PartData.CuAreaTop as nvarchar(40)),'') + ' /' END,
CASE WHEN UDFTool.StrCupBotMic=1  THEN isnull(cast(PartData.CuAreaBot as nvarchar(40)),'') +  CHAR(181)  ELSE isnull(cast(PartData.CuAreaBot as nvarchar(40)),'') END,
ISNULL (SUBSTRING (UDFTool.SalCat1,1,1),''),
ISNULL(SUBSTRING(UDFTool.SalCat2,1,1),''),
ISNULL(SUBSTRING(UDFTool.SalCat3,1,1),''),
ISNULL(SUBSTRING(UDFTool.SalCat4,1,1),''),
ISNULL(UDFTool.Spec,''),
isnull(	UDFTool.EltRepReq	,''	)EltRepReq,
isnull(	UDFTool.OutLineMin	,0	)OutLineMin,
isnull(	PartData.OutSpaceNom	,0	)OutSpaceNom,
isnull(	UDFTool.NoTolerance	,''	)NoTolerance,
isnull(	UDFTool.GoldFinWidth	,0	)GoldFinWidth,
isnull(	UDFTool.GoldFinLength	,0	)GoldFinLength,
isnull(	UDFTool.CoupPerPanel	,''	)CoupPerPanel,
isnull(	UDFTool.CroSecPanel	,''	)CroSecPanel,
isnull(	UDFTool.EltTestM40V	,''	)EltTestM40V,
isnull(	UDFTool.Drill2	,''	)Drill2,
isnull(	UDFTool.HsEtcMarking	,''	)HsEtcMarking,
isnull(	UDFTool.EtcB4Gold	,''	)EtcB4Gold,
isnull(	UDFTool.RemoveHSLeadTin	,''	)RemoveHSLeadTin,
isnull(	UDFTool.ProtPrint	,''	)ProtPrint,
isnull(	UDFTool.RoutEtch	,''	)RoutEtch,
isnull(	SUBSTRING(UDFTool.FinishingLevel,1,1)	,''	)FinishingLevel,
isnull(	UDFTool.ElectroFusing	,''	)ElectroFusing,
isnull(	UDFTool.PanelReduction	,''	)PanelReduction,
isnull(	UDFTool.NickelReqThick	,0	)NickelReqThick,
isnull(	UDFTool.RcmndedPCBsNo	,''	)RcmndedPCBsNo,
isnull(	UDFTool.Thickness	,0	)Thickness,
isnull(	UDFTool.PCBMinTick	,0	)PCBMinTick,
isnull(	UDFTool.PCBPlanTick	,0	)PCBPlanTick,
isnull(	UDFTool.MaxLam	,0	)MaxLam,
isnull(	UDFTool.LamThickMin	,0	)LamThickMin,
isnull(	PartData.LamThickNom	,0	)LamThickNom,
isnull(	UDFTool.RMThikChgForbidden	,''	)RMThikChgForbidden,
isnull(	UDFTool.CopperThikChgForbidden	,''	)CopperThikChgForbidden,
isnull(	UDFTool.PEP	,''	),
isnull(	UDFTool.NewPlanningFile	,0	) NewPlanningFile,
isnull(	cast(UDFTool.PlatingDensity as nvarchar(4000))	,''	), 
isnull(	cast(UDFTool.Tab as nvarchar(4000))	,''	),
isnull(	cast(UDFTool.Class3A as nvarchar(4000))	,''	),
isnull(	cast( UDFTool.Microwave	as nvarchar(4000)),''	),
isnull(	cast (UDFTool.Group_B	as nvarchar(4000) ) ,''	), 
ISNULL(CAST( convert (varchar(10), UDFTool.LastUpdate , 112) as int) - 19280000,0) LastUpdate,
isnull(	UDFTool.UserUpdate	,''	),
isnull(	UDFTool.WSUpdate	,''	),
isnull(	UDFTool.SelectiveCoat	,''	),
isnull(	UDFTool.Sealing	,''	),
isnull(	UDFTool.InsertInputs	,''	),
isnull(	UDFTool.SandSpray	,''	),
isnull(	UDFTool.AddrPrint	,''	),
isnull(	UDFTool.PlatingSpec1	,''	),
isnull(	UDFTool.PlatingType1	,''	),
isnull(	UDFTool.PlatingClass1	,''	),
isnull(	UDFTool.PlatingColor1	,''	),
isnull( PartData.PrintNum	,''	),
isnull(	UDFTool.PlatingType2	,''	),
isnull(	UDFTool.PlatingClass2	,''	),
isnull(	UDFTool.PlatingColor2	,''	)
			from 
			 [EventLog] [log] inner join  
			 cprt on ([log].EventKeyID = cprt.cprtID) inner join  
			 PartData  on PartData.cprtID = cprt.cprtID left join
			 UDFTool  on UDFTool.cprtsID = PartData.cprtsID
		where PartData.SubAss='1' 
			and [log].EventType = 'cprtID'  
			and ([log].EventStatus = 'UPDATE' or [log].EventStatus = 'INSERT')
			and [log].Delivered_To_AS400 = 0
				
				OPEN cur_update_itemH  
					
	FETCH NEXT FROM cur_update_itemH INTO @EVENTSTATUSH
, @HDORMG
, @HDRVMG
, @HDORPL
, @HDRVPL
, @HDNOCL    
, @HDNOPL    
, @HDOUTP    
, @HDNOTH    
, @HDOVSP    
, @HDOVSN    
, @HDSLDR    
, @HDSDCS    
, @HDSDPS    
, @HDMKCS    
, @HDMKPS    
, @HDCOLR    
, @HDHAL     
, @HDTKNA    
, @HDKUPN    
, @HDHMRG    
, @HDSMZR    
, @HDOVMZ    
, @HDSIBD    
, @HDHTML    
, @HDNAME    
, @HDTBDT    
, @HDOVS1    
, @HDOVS2    
, @HDCTMH    
, @HDCOC     
, @HDSHMG    
, @HDSHPL    
, @HDSPKG    
, @HDULRF    
, @HDSRTT    
, @HDMZHV    
, @HDTKNZ    
, @HDCLRP    
, @HDCLRC    
, @HDCLRH    
, @HDGMKR    
, @HDBNMG    
, @HDFLKD    
, @HDDRKD    
, @HDDRMC    
, @HDMSMP    
, @HDSHPD    
, @HDSGHGTOP 
, @HDSGHGBOT
, @HDCAT1   
, @HDCAT2
, @HDCAT3
, @HDCAT4
, @HDCLS3    
, @HDDHML    
, @HDMINC    
, @HDSPBC    
, @HDEXCT    
, @HDROZV    
, @HDORZV    
, @HDKUPP    
, @HDHTMP    
, @HDB40V    
, @HDKID2    
, @HDZKHS    
, @HDZPAZ    
, @HDASBO    
, @HDPMAG    
, @HDKRTS    
, @HDBOLA    
, @HDBOA     
, @HDAKPN    
, @HDOVNK    
, @HDHAM     
, @HDMMAX    
, @HDMMIN    
, @HDMMET    
, @HDKMAX    
, @HDKMIN    
, @HDKNOM    
, @HDOVCU    
, @HDOVHG    
, @HDPEP     
, @HDSTAT    
, @HDFLD21 
, @HDFLD22
, @HDFLD23
, @HDFLD24
, @HDFLD25 
, @HDLST     
, @HDUSR     
, @HDWSID    
, @HDHSLC    
, @HDHATM    
, @HDHINS    
, @HDHHOL    
, @HDHADR    
, @HDH1SP    
, @HDH1TP    
, @HDH1CL    
, @HDH1CR    
, @HDH2SP    
, @HDH2TP    
, @HDH2CL    
, @HDH2CR  


	WHILE @@FETCH_STATUS = 0   
	BEGIN 
	if @EventStatusH = 'INSERT'
		begin 
			SELECT @MainPN = '-1'
			--DECLARE @OpenSelect As nvarchar(500)
			SET @OpenSelect = 'select @MainPN = HDPROD from OPENQUERY(AS400_ODBC2,''select * from S6577E6F.HAGIT.HDS WHERE HDPROD = '''''+ @HDPROD+''''''')' 
			EXEC sp_executesql @OpenSelect, N'@MainPN nvarchar(200) out', @MainPN out
			SELECT @MainPN As Outputs 
			if @MainPN = '-1'   
				begin
	--INSERT:
	
	
		insert into  [AS400_ODBC2].[S6577E6F].[HAGIT].[HDS]
           ( 		
			HDORMG
		,	HDRVMG
		,	HDORPL
		,	HDRVPL
		,	HDNOCL    
		,	HDNOPL    
		,	HDOUTP    
		,	HDNOTH    
		,	HDOVSP    
		,	HDOVSN    
		,	HDSLDR    
		,	HDSDCS    
		,	HDSDPS    
		,	HDMKCS    
		,	HDMKPS    
		,	HDCOLR    
		,	HDHAL     
		,	HDTKNA    
		,	HDKUPN    
		,	HDHMRG    
		,	HDSMZR    
		,	HDOVMZ    
		,	HDSIBD    
		,	HDHTML    
		,	HDNAME    
		,	HDTBDT    
		,	HDOVS1    
		,	HDOVS2    
		,	HDCTMH    
		,	HDCOC     
		,	HDSHMG    
		,	HDSHPL    
		,	HDSPKG    
		,	HDULRF    
		,	HDSRTT    
		,	HDMZHV    
		,	HDTKNZ    
		,	HDCLRP    
		,	HDCLRC    
		,	HDCLRH    
		,	HDGMKR    
		,	HDBNMG    
		,	HDFLKD    
		,	HDDRKD    
		,	HDDRMC    
		,	HDMSMP    
		,	HDSHPD    
		,	HDSGHG 
		,	HDCATG
		,	HDCLS3
		,	HDDHML    
		,	HDMINC    
		,	HDSPBC    
		,	HDEXCT    
		,	HDROZV    
		,	HDORZV    
		,	HDKUPP    
		,	HDHTMP    
		,	HDB40V    
		,	HDKID2    
		,	HDZKHS    
		,	HDZPAZ    
		,	HDASBO    
		,	HDPMAG    
		,	HDKRTS    
		,	HDBOLA    
		,	HDBOA     
		,	HDAKPN    
		,	HDOVNK    
		,	HDHAM     
		,	HDMMAX    
		,	HDMMIN    
		,	HDMMET    
		,	HDKMAX    
		,	HDKMIN    
		,	HDKNOM    
		,	HDOVCU    
		,	HDOVHG    
		,	HDPEP     
		,	HDSTAT    
		,	HDFLD2
		,	HDLST     
		,	HDUSR     
		,	HDWSID    
		,	HDHSLC    
		,	HDHATM    
		,	HDHINS    
		,	HDHHOL    
		,	HDHADR    
		,	HDH1SP    
		,	HDH1TP    
		,	HDH1CL    
		,	HDH1CR    
		,	HDH2SP    
		,	HDH2TP    
		,	HDH2CL    
		,	HDH2CR  
	)
	 

VALUES
(		
		  @HDORMG
		, @HDRVMG
		, @HDORPL
		, @HDRVPL
		, @HDNOCL    
		, @HDNOPL    
		, @HDOUTP    
		, @HDNOTH    
		, @HDOVSP    
		, @HDOVSN    
		, @HDSLDR    
		, @HDSDCS    
		, @HDSDPS    
		, @HDMKCS    
		, @HDMKPS    
		, @HDCOLR    
		, @HDHAL     
		, @HDTKNA    
		, @HDKUPN    
		, @HDHMRG    
		, @HDSMZR    
		, @HDOVMZ    
		, @HDSIBD    
		, @HDHTML    
		, @HDNAME    
		, @HDTBDT    
		, @HDOVS1    
		, @HDOVS2    
		, @HDCTMH    
		, @HDCOC     
		, @HDSHMG    
		, @HDSHPL    
		, @HDSPKG    
		, @HDULRF    
		, @HDSRTT    
		, @HDMZHV    
		, @HDTKNZ    
		, @HDCLRP    
		, @HDCLRC    
		, @HDCLRH    
		, @HDGMKR    
		, @HDBNMG    
		, @HDFLKD    
		, @HDDRKD    
		, @HDDRMC    
		, @HDMSMP    
		, @HDSHPD    
		, @HDSGHGTOP + @HDSGHGBOT
		, @HDCAT4+@HDCAT3+@HDCAT2+@HDCAT1   
		, @HDCLS3    
		, @HDDHML    
		, @HDMINC    
		, @HDSPBC    
		, @HDEXCT    
		, @HDROZV    
		, @HDORZV    
		, @HDKUPP    
		, @HDHTMP    
		, @HDB40V    
		, @HDKID2    
		, @HDZKHS    
		, @HDZPAZ    
		, @HDASBO    
		, @HDPMAG    
		, @HDKRTS    
		, @HDBOLA    
		, @HDBOA     
		, @HDAKPN    
		, @HDOVNK    
		, @HDHAM     
		, @HDMMAX    
		, @HDMMIN    
		, @HDMMET    
		, @HDKMAX    
		, @HDKMIN    
		, @HDKNOM    
		, @HDOVCU    
		, @HDOVHG    
		, @HDPEP     
		, @HDSTAT    
		, @HDFLD21 + @HDFLD22+@HDFLD23+@HDFLD24 +@HDFLD25 
		, @HDLST     
		, @HDUSR     
		, @HDWSID    
		, @HDHSLC    
		, @HDHATM    
		, @HDHINS    
		, @HDHHOL    
		, @HDHADR    
		, @HDH1SP    
		, @HDH1TP    
		, @HDH1CL    
		, @HDH1CR    
		, @HDH2SP    
		, @HDH2TP    
		, @HDH2CL    
		, @HDH2CR  
)
	
	
				   PRINT  @HDPROD + ' Creating' 
				end
			else
				PRINT  @HDPROD + ' Exists'	

	 	end
	 	else
	 	begin
	--UPDATE:
		SELECT  @TSQL = 'UPDATE OPENQUERY(AS400_ODBC2,
			''select * from S6577E6F.HAGIT.HDS WHERE HDPROD = '''''+ @HDPROD+''''''') 
SET	HDPROD= '''+  @HDPROD +'''
,   HDORMG	=	'+ CAST(@HDORMG AS NVARCHAR(100))	+'
,	HDRVMG	=	'+ CAST(@HDRVMG AS NVARCHAR(100))	+'
,	HDORPL	=	'+ CAST(@HDORPL AS NVARCHAR(100))	+'
,	HDRVPL	=	'+ CAST(@HDRVPL AS NVARCHAR(100))	+'
,	HDNOCL    	=	'+ CAST(@HDNOCL     AS NVARCHAR(100))	+'
,	HDNOPL    	=	'+ CAST(@HDNOPL     AS NVARCHAR(100))	+'
,	HDOUTP    	=	'''+	@HDOUTP    	+'''
,	HDNOTH    	=    '+ CAST(@HDNOTH  AS NVARCHAR(100))	+'
,	HDOVSP    	=    '+ CAST(@HDOVSP  AS NVARCHAR(100))	+'
,	HDOVSN    	=    '+ CAST(@HDOVSN  AS NVARCHAR(100))	+'
,	HDSLDR    	=	'''+	@HDSLDR    	+'''
,	HDSDCS    	=	'''+	@HDSDCS    	+'''
,	HDSDPS    	=	'''+	@HDSDPS    	+'''
,	HDMKCS    	=	'''+	@HDMKCS    	+'''
,	HDMKPS    	=	'''+	@HDMKPS    	+'''
,	HDCOLR    	=	'''+	@HDCOLR    	+'''
,	HDHAL     	=	'''+	@HDHAL     	+'''
,	HDTKNA    	=	'''+	@HDTKNA    	+'''
,	HDKUPN    	=	'''+	@HDKUPN    	+'''
,	HDHMRG    	=    '+ CAST(@HDHMRG  AS NVARCHAR(100))	+'
,	HDSMZR    	=	'''+	@HDSMZR    	+'''
,	HDOVMZ    	=    '+ CAST(@HDOVMZ  AS NVARCHAR(100))	+'
,	HDSIBD    	=	'''+	@HDSIBD    	+'''
,	HDHTML    	=	'''+	@HDHTML    	+'''
,	HDNAME    	=	'''+	@HDNAME    	+'''
,	HDTBDT    	=	'''+	@HDTBDT    	+'''
,	HDOVS1    	=    '+ CAST(@HDOVS1  AS NVARCHAR(100))	+'
,	HDOVS2    	=    '+ CAST(@HDOVS2  AS NVARCHAR(100))	+'
,	HDCTMH    	=	'''+	@HDCTMH    	+'''
,	HDCOC     	=	'''+	@HDCOC     	+'''
,	HDSHMG    	=    '+ CAST(@HDSHMG  AS NVARCHAR(100))	+'
,	HDSHPL    	=    '+ CAST(@HDSHPL  AS NVARCHAR(100))	+'
,	HDSPKG    	=	'''+	@HDSPKG    	+'''
,	HDULRF    	=	'''+	@HDULRF    	+'''
,	HDSRTT    	=	'''+	@HDSRTT    	+'''
,	HDMZHV    	=    '+ CAST(@HDMZHV  AS NVARCHAR(100))	+'
,	HDTKNZ    	=	'''+	@HDTKNZ    	+'''
,	HDCLRP    	=	'''+	@HDCLRP    	+'''
,	HDCLRC    	=	'''+	@HDCLRC    	+'''
,	HDCLRH    	=	'''+	@HDCLRH    	+'''
,	HDGMKR    	=	'''+	@HDGMKR    	+'''
,	HDBNMG    	=	'''+	@HDBNMG    	+'''
,	HDFLKD    	=	'''+	@HDFLKD    	+'''
,	HDDRKD    	=	'''+	@HDDRKD    	+'''
,	HDDRMC    	=	'''+	@HDDRMC    	+'''
,	HDMSMP    	=    '+ CAST(@HDMSMP     AS NVARCHAR(100))	+'
,	HDSHPD    	=    '+ CAST(@HDSHPD     AS NVARCHAR(100))	+'
,	HDSGHG    	=	'''+	@HDSGHGTOP + @HDSGHGBOT    	+'''
,	HDCATG    	=	'''+	@HDCAT4+@HDCAT3+@HDCAT2+@HDCAT1 +'''
,	HDCAT1    	=	'''+	@HDCAT1    	+'''
,	HDCAT2    	=	'''+	@HDCAT2    	+'''
,	HDCAT3    	=	'''+	@HDCAT3    	+'''
,	HDCAT4    	=	'''+	@HDCAT4    	+'''
,	HDCLS3    	=	'''+	@HDCLS3    	+'''
,	HDDHML    	=	'''+	@HDDHML    	+'''
,	HDMINC    	=    '+ CAST(@HDMINC     AS NVARCHAR(100))	+'
,	HDSPBC    	=    '+ CAST(@HDSPBC     AS NVARCHAR(100))	+'
,	HDEXCT    	=	'''+	@HDEXCT    	+'''
,	HDROZV    	=    '+ CAST(@HDROZV     AS NVARCHAR(100))	+'
,	HDORZV    	=    '+ CAST(@HDORZV     AS NVARCHAR(100))	+'
,	HDKUPP    	=	'''+	@HDKUPP    	+'''
,	HDHTMP    	=	'''+	@HDHTMP    	+'''
,	HDB40V    	=	'''+	@HDB40V    	+'''
,	HDKID2    	=	'''+	@HDKID2    	+'''
,	HDZKHS    	=	'''+	@HDZKHS    	+'''
,	HDZPAZ    	=	'''+	@HDZPAZ    	+'''
,	HDASBO    	=	'''+	@HDASBO    	+'''
,	HDPMAG    	=	'''+	@HDPMAG    	+'''
,	HDKRTS    	=	'''+	@HDKRTS    	+'''
,	HDBOLA    	=	'''+	@HDBOLA    	+'''
,	HDBOA     	=	'''+	@HDBOA     	+'''
,	HDAKPN    	=	'''+	@HDAKPN    	+'''
,	HDOVNK    	=    '+ CAST(@HDOVNK     AS NVARCHAR(100))	+'
,	HDHAM     	=	'''+	@HDHAM     	+'''
,	HDMMAX    	=    '+ CAST(@HDMMAX     AS NVARCHAR(100))	+'
,	HDMMIN    	=    '+ CAST(@HDMMIN     AS NVARCHAR(100))	+'
,	HDMMET    	=    '+ CAST(@HDMMET     AS NVARCHAR(100))	+'
,	HDKMAX    	=    '+ CAST(@HDKMAX     AS NVARCHAR(100))	+'
,	HDKMIN    	=    '+ CAST(@HDKMIN     AS NVARCHAR(100))	+'
,	HDKNOM    	=    '+ CAST(@HDKNOM     AS NVARCHAR(100))	+'
,	HDOVCU    	=	'''+	@HDOVCU    	+'''
,	HDOVHG    	=	'''+	@HDOVHG    	+'''
,	HDPEP     	=	'''+	@HDPEP     	+'''
,	HDSTAT    	=    '+ CAST(@HDSTAT     AS NVARCHAR(100))	+'
,	HDFLD2	=	'''+	@HDFLD21 + @HDFLD22	+@HDFLD23 +@HDFLD24 +@HDFLD25 +'''
,	HDLST     	=    '+ CAST(@HDLST      AS NVARCHAR(100))	+'
,	HDUSR     	=	'''+	@HDUSR     	+'''
,	HDWSID    	=	'''+	@HDWSID    	+'''
,	HDHSLC    	=	'''+	@HDHSLC    	+'''
,	HDHATM    	=	'''+	@HDHATM    	+'''
,	HDHINS    	=	'''+	@HDHINS    	+'''
,	HDHHOL    	=	'''+	@HDHHOL    	+'''
,	HDHADR    	=	'''+	@HDHADR    	+'''
,	HDH1SP    	=	'''+	@HDH1SP    	+'''
,	HDH1TP    	=	'''+	@HDH1TP    	+'''
,	HDH1CL    	=	'''+	@HDH1CL    	+'''
,	HDH1CR    	=	'''+	@HDH1CR    	+'''
,	HDH2SP    	=	'''+	@HDH2SP    	+'''
,	HDH2TP    	=	'''+	@HDH2TP    	+'''
,	HDH2CL    	=	'''+	@HDH2CL    	+'''
,	HDH2CR    	=	'''+	@HDH2CR    	+''''
			
		PRINT (@TSQL)	
		EXEC (@TSQL)			
	END
					
	FETCH NEXT FROM cur_update_itemH INTO @EVENTSTATUSH,
  @HDORMG
, @HDRVMG
, @HDORPL
, @HDRVPL
, @HDNOCL    
, @HDNOPL    
, @HDOUTP    
, @HDNOTH    
, @HDOVSP    
, @HDOVSN    
, @HDSLDR    
, @HDSDCS    
, @HDSDPS    
, @HDMKCS    
, @HDMKPS    
, @HDCOLR    
, @HDHAL     
, @HDTKNA    
, @HDKUPN    
, @HDHMRG    
, @HDSMZR    
, @HDOVMZ    
, @HDSIBD    
, @HDHTML    
, @HDNAME    
, @HDTBDT    
, @HDOVS1    
, @HDOVS2    
, @HDCTMH    
, @HDCOC     
, @HDSHMG    
, @HDSHPL    
, @HDSPKG    
, @HDULRF    
, @HDSRTT    
, @HDMZHV    
, @HDTKNZ    
, @HDCLRP    
, @HDCLRC    
, @HDCLRH    
, @HDGMKR    
, @HDBNMG    
, @HDFLKD    
, @HDDRKD    
, @HDDRMC    
, @HDMSMP    
, @HDSHPD    
, @HDSGHGTOP 
 ,@HDSGHGBOT
,@HDCAT1   
,@HDCAT2
,@HDCAT3
,@HDCAT4
, @HDCLS3    
, @HDDHML    
, @HDMINC    
, @HDSPBC    
, @HDEXCT    
, @HDROZV    
, @HDORZV    
, @HDKUPP    
, @HDHTMP    
, @HDB40V    
, @HDKID2    
, @HDZKHS    
, @HDZPAZ    
, @HDASBO    
, @HDPMAG    
, @HDKRTS    
, @HDBOLA    
, @HDBOA     
, @HDAKPN    
, @HDOVNK    
, @HDHAM     
, @HDMMAX    
, @HDMMIN    
, @HDMMET    
, @HDKMAX    
, @HDKMIN    
, @HDKNOM    
, @HDOVCU    
, @HDOVHG    
, @HDPEP     
, @HDSTAT    
, @HDFLD21 
,@HDFLD22
, @HDFLD23
,@HDFLD24
,@HDFLD25 
, @HDLST     
, @HDUSR     
, @HDWSID    
, @HDHSLC    
, @HDHATM    
, @HDHINS    
, @HDHHOL    
, @HDHADR    
, @HDH1SP    
, @HDH1TP    
, @HDH1CL    
, @HDH1CR    
, @HDH2SP    
, @HDH2TP    
, @HDH2CL    
, @HDH2CR  	
					
--	FETCH NEXT FROM cur_update_itemH INTO @EVENTSTATUSH, @HDPROD, @HDORMG,@HDRVMG,@HDORPL,@HDRVPL,@HDNOCL ,@HDNOPL,@HDOUTP ,@HDNOTH  ,@HDOVSP ,@HDOVSN ,@HDSLDR ,
--@HDSDCS ,@HDSDPS ,@HDMKCS ,@HDMKPS ,@HDCOLR,@HDHAL,@HDTKNA,@HDKUPN,@HDHMRG,@HDSMZR,@HDOVMZ,@HDSIBD,@HDHTML ,@HDNAME ,@HDTBDT ,
--@HDOVS1,@HDOVS2 ,@HDCTMH ,@HDCOC,@HDSHMG,@HDSHPL,@HDSPKG ,@HDULRF ,@HDSRTT ,@HDMZHV  ,@HDTKNZ ,@HDCLRP ,@HDCLRC,@HDCLRH ,@HDGMKR,@HDBNMG  ,@HDFLKD ,@HDDRKD ,@HDDRMC,@HDMSMP,
--@HDSHPD ,@HDSGHGTOP,@HDSGHGBOT, @HDCAT1 ,@HDCAT2 ,@HDCAT3 ,@HDCAT4, @HDCATG  ,@HDCLS3 ,@HDDHML  ,@HDMINC ,@HDSPBC,@HDEXCT ,@HDROZV,@HDORZV,@HDKUPP ,@HDHTMP,@HDB40V ,@HDKID2 ,@HDZKHS ,
--@HDZPAZ ,@HDASBO ,@HDPMAG ,@HDKRTS ,@HDBOLA,@HDBOA,@HDAKPN ,@HDOVNK ,@HDHAM  ,@HDMMAX ,
--@HDMMIN    	,@HDMMET    	,@HDKMAX    	,@HDKMIN    	,@HDKNOM    	,@HDOVCU    	,@HDOVHG    	,@HDPEP     	,@HDSTAT    	,@HDFLD21	,@HDFLD22	,@HDFLD23	,
--@HDFLD24	,@HDFLD25	,@HDLST     	,@HDUSR     	,@HDWSID    	,@HDHSLC    	,@HDHATM    	,@HDHINS    	,@HDHHOL    	,
--@HDHADR    	,@HDH1SP    	,@HDH1TP    	,@HDH1CL    	,@HDH1CR    	,@HDH2SP    	,@HDH2TP    	,@HDH2CL    	,@HDH2CR    	

 
	END    

	CLOSE cur_update_itemH   
	DEALLOCATE cur_update_itemH
 END 

Open in new window

0
Comment
Question by:Hagita
2 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
Comment Utility
When I line them up, I have one more item in your cursor definition than in the list of variables. If I had to guess, I think the mistake might be in the first couple of variables.

@EVENTSTATUSH			EventStatus,
, @HDORMG			isnull(CPRT.ToolNum      ,''),      
, @HDRVMG			isnull(      PartData.BoardLength      ,0      ),
, @HDORPL			isnull(      PartData.BoardWidth      ,0      ),
, @HDRVPL			isnull(      PartData.PanelLength      ,0      ),
, @HDNOCL    			isnull(      PartData.PanelWidth      ,0      ),
, @HDNOPL    			isnull(      PartData.LayerTo      ,0      ) LayerTo,
, @HDOUTP    			isnull(      UDFTool.ProdLayers      ,0      )ProdLayers,
, @HDNOTH    			isnull(      UDFTool.OutsideLayers      ,''      )OutsideLayers,
, @HDOVSP    			isnull(      UDFTool.GoldFinNum      ,0      )GoldFinNum,
, @HDOVSN    			isnull(      PartData.FinThickNom      ,0      )FinThickNom,
, @HDSLDR    			isnull(      PartData.GoldThick      ,0      )GoldThick,
, @HDSDCS    			isnull(      SUBSTRING(UDFTool.SolderType,1,1),''      )SolderType,
, @HDSDPS    			isnull(      UDFTool.SolderCS      ,''      )SolderCS,
, @HDMKCS    			isnull(      UDFTool.SolderPS      ,''      )SolderPS,
, @HDMKPS    			isnull(      UDFTool.MarkingCS      ,''      )MarkingCS,
, @HDCOLR    			isnull(      UDFTool.MarkingPS      ,''      )MarkingPS,
, @HDHAL     			isnull(      SUBSTRING(PartData.LegType,1,1)      ,''      )LegType,
, @HDTKNA    			isnull(      UDFTool.HAL      ,''      )HAL,
, @HDKUPN    			isnull(      UDFTool.CivilStandard      ,''      )CivilStandard,
, @HDHMRG    			isnull(      UDFTool.SampleCoupon      ,''      )SampleCoupon,
, @HDSMZR    			isnull(      UDFTool.SpecRMTick      ,0      )SpecRMTick,
, @HDOVMZ    			isnull(      UDFTool.HSType      ,''      )HSType,
, @HDSIBD    			isnull(      UDFTool.HSTick      ,0      )HSTick,
, @HDHTML    			isnull(      SUBSTRING(UDFTool.HSProcess      ,1,1)      ,''      )HSProcess,
, @HDNAME    			isnull(      UDFTool.SampleCroSec      ,''      )SampleCroSec,
, @HDTBDT    			isnull(      UDFTool.Engineer      ,''      )Engineer,
, @HDOVS1    			isnull(      UDFTool.DateCode      ,''      )DateCode,
, @HDOVS2    			isnull(      UDFTool.MinCuSecondCoat      ,0      )MinCuSecondCoat,
, @HDCTMH    			isnull(      UDFTool.MinTinLead      ,0      )MinTinLead,
, @HDCOC     			isnull(      UDFTool.HSMarking      ,''      )HSMarking,
, @HDSHMG    			isnull(      UDFTool.COCReq      ,''      )COCReq,
, @HDSHPL    			isnull(      UDFTool.PCBAreaDm2      ,0      )PCBAreaDm2,
, @HDSPKG    			isnull(      UDFTool.PanelAreaIn2      ,0      )PanelAreaIn2,
, @HDULRF    			isnull(      UDFTool.PackingSpec      ,''      )PackingSpec,
, @HDSRTT    			isnull(      UDFTool.ULRefReq      ,''      )ULRefReq,
, @HDMZHV    			isnull( SUBSTRING(UDFTool.DrawNum,1,10)      ,''      )DrawNum,
, @HDTKNZ    			isnull(      UDFTool.GoldW      ,0      )GoldW,
, @HDCLRP    			isnull(      UDFTool.MilitaryStandard      ,''      )MilitaryStandard,
, @HDCLRC    			isnull( SUBSTRING(      UDFTool.MarkingColPS,1,1)      ,''      )MarkingColPS,
, @HDCLRH    			isnull(      SUBSTRING(  UDFTool.MarkingColCS,1,1)      ,''      )MarkingColCS,
, @HDGMKR    			isnull(      SUBSTRING(      UDFTool.MarkingColHS,1,1)      ,''      )MarkingColHS,
, @HDBNMG    			isnull(      UDFTool.OriginalFilms      ,''      )OriginalFilms,
, @HDFLKD    			isnull(      UDFTool.MagneticDB      ,''      )MagneticDB,
, @HDDRKD    			isnull(      UDFTool.DielectricDistanceReq      ,''      )DielectricDistanceReq,
, @HDDRMC    			isnull(      UDFTool.MechanicalDrillLayout      ,''      )MechanicalDrillLayout,
, @HDMSMP    			isnull(      UDFTool.XYCutsReq      ,''      )XYCutsReq,
, @HDSHPD    			isnull(      PartData.PanelUP      ,0      )PanelUP,
, @HDSGHGTOP 			isnull(      UDFTool.PanelAreaDm2      ,0      )PanelAreaDm2,
, @HDSGHGBOT			CASE WHEN UDFTool.StrCupTopMic=1  THEN isnull(cast(PartData.CuAreaTop as nvarchar(40)),'') +  CHAR(181) + ' / '  ELSE isnull(cast(PartData.CuAreaTop as nvarchar(40)),'') + ' /' END,
, @HDCAT1   			CASE WHEN UDFTool.StrCupBotMic=1  THEN isnull(cast(PartData.CuAreaBot as nvarchar(40)),'') +  CHAR(181)  ELSE isnull(cast(PartData.CuAreaBot as nvarchar(40)),'') END,
, @HDCAT2			ISNULL (SUBSTRING (UDFTool.SalCat1,1,1),''),
, @HDCAT3			ISNULL(SUBSTRING(UDFTool.SalCat2,1,1),''),
, @HDCAT4			ISNULL(SUBSTRING(UDFTool.SalCat3,1,1),''),
, @HDCLS3    			ISNULL(SUBSTRING(UDFTool.SalCat4,1,1),''),
, @HDDHML    			ISNULL(UDFTool.Spec,''),
, @HDMINC    			isnull(      UDFTool.EltRepReq      ,''      )EltRepReq,
, @HDSPBC    			isnull(      UDFTool.OutLineMin      ,0      )OutLineMin,
, @HDEXCT    			isnull(      PartData.OutSpaceNom      ,0      )OutSpaceNom,
, @HDROZV    			isnull(      UDFTool.NoTolerance      ,''      )NoTolerance,
, @HDORZV    			isnull(      UDFTool.GoldFinWidth      ,0      )GoldFinWidth,
, @HDKUPP    			isnull(      UDFTool.GoldFinLength      ,0      )GoldFinLength,
, @HDHTMP    			isnull(      UDFTool.CoupPerPanel      ,''      )CoupPerPanel,
, @HDB40V    			isnull(      UDFTool.CroSecPanel      ,''      )CroSecPanel,
, @HDKID2    			isnull(      UDFTool.EltTestM40V      ,''      )EltTestM40V,
, @HDZKHS    			isnull(      UDFTool.Drill2      ,''      )Drill2,
, @HDZPAZ    			isnull(      UDFTool.HsEtcMarking      ,''      )HsEtcMarking,
, @HDASBO    			isnull(      UDFTool.EtcB4Gold      ,''      )EtcB4Gold,
, @HDPMAG    			isnull(      UDFTool.RemoveHSLeadTin      ,''      )RemoveHSLeadTin,
, @HDKRTS    			isnull(      UDFTool.ProtPrint      ,''      )ProtPrint,
, @HDBOLA    			isnull(      UDFTool.RoutEtch      ,''      )RoutEtch,
, @HDBOA     			isnull(      SUBSTRING(UDFTool.FinishingLevel,1,1)      ,''      )FinishingLevel,
, @HDAKPN    			isnull(      UDFTool.ElectroFusing      ,''      )ElectroFusing,
, @HDOVNK    			isnull(      UDFTool.PanelReduction      ,''      )PanelReduction,
, @HDHAM     			isnull(      UDFTool.NickelReqThick      ,0      )NickelReqThick,
, @HDMMAX    			isnull(      UDFTool.RcmndedPCBsNo      ,''      )RcmndedPCBsNo,
, @HDMMIN    			isnull(      UDFTool.Thickness      ,0      )Thickness,
, @HDMMET    			isnull(      UDFTool.PCBMinTick      ,0      )PCBMinTick,
, @HDKMAX    			isnull(      UDFTool.PCBPlanTick      ,0      )PCBPlanTick,
, @HDKMIN    			isnull(      UDFTool.MaxLam      ,0      )MaxLam,
, @HDKNOM    			isnull(      UDFTool.LamThickMin      ,0      )LamThickMin,
, @HDOVCU    			isnull(      PartData.LamThickNom      ,0      )LamThickNom,
, @HDOVHG    			isnull(      UDFTool.RMThikChgForbidden      ,''      )RMThikChgForbidden,
, @HDPEP     			isnull(      UDFTool.CopperThikChgForbidden      ,''      )CopperThikChgForbidden,
, @HDSTAT    			isnull(      UDFTool.PEP      ,''      ),
, @HDFLD21 			isnull(      UDFTool.NewPlanningFile      ,0      ) NewPlanningFile,
, @HDFLD22			isnull(      cast(UDFTool.PlatingDensity as nvarchar(4000))      ,''      ), 
, @HDFLD23			isnull(      cast(UDFTool.Tab as nvarchar(4000))      ,''      ),
, @HDFLD24			isnull(      cast(UDFTool.Class3A as nvarchar(4000))      ,''      ),
, @HDFLD25 			isnull(      cast( UDFTool.Microwave      as nvarchar(4000)),''      ),
, @HDLST     			isnull(      cast (UDFTool.Group_B      as nvarchar(4000) ) ,''      ), 
, @HDUSR     			ISNULL(CAST( convert (varchar(10), UDFTool.LastUpdate , 112) as int) - 19280000,0) LastUpdate,
, @HDWSID    			isnull(      UDFTool.UserUpdate      ,''      ),
, @HDHSLC    			isnull(      UDFTool.WSUpdate      ,''      ),
, @HDHATM    			isnull(      UDFTool.SelectiveCoat      ,''      ),
, @HDHINS    			isnull(      UDFTool.Sealing      ,''      ),
, @HDHHOL    			isnull(      UDFTool.InsertInputs      ,''      ),
, @HDHADR    			isnull(      UDFTool.SandSpray      ,''      ),
, @HDH1SP    			isnull(      UDFTool.AddrPrint      ,''      ),
, @HDH1TP    			isnull(      UDFTool.PlatingSpec1      ,''      ),
, @HDH1CL    			isnull(      UDFTool.PlatingType1      ,''      ),
, @HDH1CR    			isnull(      UDFTool.PlatingClass1      ,''      ),
, @HDH2SP    			isnull(      UDFTool.PlatingColor1      ,''      ),
, @HDH2TP    			isnull( PartData.PrintNum      ,''      ),
, @HDH2CL    			isnull(      UDFTool.PlatingType2      ,''      ),
, @HDH2CR  			isnull(      UDFTool.PlatingClass2      ,''      ),
			isnull(      UDFTool.PlatingColor2      ,''      )

Open in new window

0
 

Author Comment

by:Hagita
Comment Utility
Thank you mankowitz..Found the missing variable
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now