﻿USE [FabApprovalSystem]
GO
	/****** Object:  StoredProcedure [dbo].[MRBDeleteAllLots]    Script Date: 11/21/2024 11:29:05 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	CREATE PROCEDURE [dbo].[MRBDeleteAllLots] @MRBNumber INT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
SET
	NOCOUNT ON;

DELETE FROM
	MRBLot
WHERE
	MRBNumber = @MRBNumber DELETE MRBLotsToBeSentToSPN
WHERE
	MRBNumber = @MRBNumber
	AND SentToSPN = 0
UPDATE
	MRBLotsToBeSentToSPN
SET
	AddRemoveChangeMRBFlag = 'R'
WHERE
	MRBNumber = @MRBNumber
	AND SentToSPN = 1
UPDATE
	MRB
SET
	NumberOfLotsAffected = 0,
	NumberOfWafersAffected = 0,
	NumberOfDiesAffected = 0
WHERE
	MRBNumber = @MRBNumber
END
GO