DROP PROCEDURE GrabarDetCtrlFuelProc
GO
CREATE PROCEDURE GrabarDetCtrlFuelProc
(	@CORRNBR int

)
AS
BEGIN    

	DECLARE   @ERROR	integer


       INSERT 	INTO 	OP_CTRLFUELDET(SITEID,DATEPROCE,INVTIDSKU,STOCKINITIAL,QTYIMPUT,QTYOUTPUT,QTYSALES,QTYAVAIL,STKUINITID,VALUEUNIMED,QTYPHISICAL,QTYDIFFERENCE,PORCENTDIFERENCE,REMARK)
		SELECT 	SITEID,DATEPROCE,INVTIDSKU,STOCKINITIAL,QTYIMPUT,QTYOUTPUT,QTYSALES,QTYAVAIL,STKUINITID,VALUEUNIMED,QTYPHISICAL,QTYDIFFERENCE,PORCENTDIFERENCE,REMARK
		FROM	TMP_OP_CTRLFUELDET
		WHERE	CORRNBR=@CORRNBR

	IF (@@error!=0 OR @@ROWCOUNT=0 )
    	BEGIN
        	RETURN(1)
    	END

  RETURN (0)

END


SELECT * FROM TMP_OP_CTRLFUELDET
SELECT * FROM OP_CTRLFUELDET