I am trying to update my script from the RAISERROR Command to the THROW Command. I am in a "If statement" condition and if the contidion is True return the error. For the RAISEERROR command I do not have an issue, however when I change to the THROW Command, there is no possible.
RAISERROR Command:
CREATE OR ALTER PROCEDURE Auction.uspAddProductToAuction
(@ProductID INT,@ExpireDate DATETIME = NULL,@InitialBidPrice MONEY = NULL) AS
DECLARE @IND_ADD_PRODUCT TINYINT
SET @IND_ADD_PRODUCT=1
IF ([Auction].[ufnGetStock](@ProductID)=0) --> true
BEGIN
SET @IND_ADD_PRODUCT = 0
RAISERROR ('The product is not in auction campaign discount or a product was not inserted',1,0)
END
THROW Command:
CREATE OR ALTER PROCEDURE Auction.uspAddProductToAuction
(@ProductID INT,@ExpireDate DATETIME = NULL,@InitialBidPrice MONEY = NULL) AS
DECLARE @IND_ADD_PRODUCT TINYINT
SET @IND_ADD_PRODUCT=1
IF ([Auction].[ufnGetStock](@ProductID)=0) --> true
BEGIN
SET @IND_ADD_PRODUCT = 0
THROW 50001, 'The product is not in auction campaign discount or a product was not inserted',0
END
Error: "Msg 102, Level 15, State 1, Procedure uspAddProductToAuction, Line 14 [Batch Start Line 180] Incorrect syntax near 'THROW'."
Thank you in advance
Aucun commentaire:
Enregistrer un commentaire