|
Hi Everyone.
I'm finding it hard to get information of verifying variables passed into a stored procedure. Specifically if the value is NULL then I want to abort the procedure and let VB.NET know the insert failed without issuing an exception.
I found some information that gave me the following IF statement but the layout is not like VB so I'm not sure where to go from here...
IF (@RateLevel1 IS NOT NULL) OR (@RateLevel2 IS NOT NULL)
NOTE: I borrowed the following code from a tutorial video so if you find any issues please let me know.
ALTER PROCEDURE dbo.sptblBillingRatesInsert
(
@Description nvarchar(150),
@RateLevel1 money,
@RateLevel2 money,
@RateLevel3 money,
@RateLevel4 money,
@RateLevel5 money,
@BillingLevelID int OUTPUT,
@ModifiedStamp timestamp OUTPUT
)
AS
SET NOCOUNT ON;
-- Inserts a row in Billing Rates
INSERT INTO tblBillingRates
(Description, RateLevel1, RateLevel2, RateLevel3, RateLevel4, RateLevel5)
VALUES
(@Description, @RateLevel1, @RateLevel2, @RateLevel3, @RateLevel4, @RateLevel5);
-- Checks if the last statement produced an error
IF @@ROWCOUNT>0 AND @@ERROR=0
SELECT @BillingLevelID = BillingLevelID, @ModifiedStamp = ModifiedStamp
FROM tblBillingRates
WHERE (BillingLevelID = SCOPE_IDENTITY());
|
|
|
|