﻿/*************************************
* STORED PROCEDURE stp_MovMag_insert
*
*  insert record movimenti magazzino
*
* mod : 27/11/2015	
* aut : S.E. Locatelli
**************************************/
CREATE PROCEDURE [dbo].[stp_MovMag_insert]
(
      @idxItem		INT = 0
    , @numIntMtz	INT
    , @Qta		INT
)
AS

BEGIN tran
    -- calcolo macchina...
    DECLARE @idxMacchina	INT = 0

    SELECT  @idxMacchina	   = idxMacchina
    FROM	  InterventiMtz
    WHERE	  numIntMtz	   = @numIntMtz

    INSERT INTO MovMagRic(idxItem,numIntMtz,dtMov,Qta,idxMacchina)
    VALUES(@idxItem,@numIntMtz,GETDATE(),@Qta,@idxMacchina)

COMMIT tran
RETURN