vbnetcoder
asked on
STORED procedure paramters delete
In the following stored procedure BOTH images get deleted regardless of what is passed in for @ImageType.
Why
Why
USE [Store]
GO
/****** Object: StoredProcedure [dbo].[spDeleteImage] Script Date: 03/17/2011 14:59:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spDeleteImage]
-- Add the parameters for the stored procedure here
@Product_ID int,
@ImageType varchar(5)
AS
SET NOCOUNT ON;
IF @ImageType = 'main'
BEGIN
declare @Product_Image int
SELECT @Product_Image = Product_Image FROM Products WHERE Product_ID= @Product_ID
UPDATE Products SET Product_Image = null WHERE Product_ID = @Product_Image
DELETE FROM Images WHERE Image_ID = @Product_Image
END
IF @ImageType = 'thumb'
BEGIN
DECLARE @Product_Thumb int
SELECT @Product_Thumb = Product_Thumb FROM Products WHERE Product_ID = @Product_ID
UPDATE ProductS SET Product_Thumb = null WHERE Product_Thumb = @Product_ID
DELETE FROM Images WHERE Image_ID = @Product_Thumb
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.