这是执行部分
DECLARE @return_value int
EXEC @return_value = [dbo].[SPM_GetBidderSupplier]
@txtName = NULL,
@txtPOBox = NULL,
@txtAddress = NULL,
@ddlCity = NULL,
@txtDistrict = NULL,
@ddlProvince = NULL,
@txtPostalZC = NULL,
@txtSupplier = NULL,
@txtBidderID = NULL,
@ddlStanding = NULL,
@txtPartnerfunction = NULL,
@txtParentSupplier = NULL,
@ddlBidderStatus = NULL,
@txtBidderNotes = NULL
SELECT 'Return Value' = @return_value
GO
这是实际的存储过程
/*
Created By: Ace Nasir
Created Date: 19 August 2014
*/
--exec SPM_GetBidderSupplier
ALTER PROCEDURE [dbo].[SPM_GetBidderSupplier]
(@txtName varchar,
@txtPOBox varchar,
@txtAddress varchar,
@ddlCity varchar,
@txtDistrict varchar,
@ddlProvince varchar,
@txtPostalZC varchar,
@txtSupplier varchar,
@txtBidderID varchar,
@ddlStanding varchar,
@txtPartnerfunction varchar,
@txtParentSupplier varchar,
@ddlBidderStatus varchar,
@txtBidderNotes varchar)
AS
SET NOCOUNT ON;
/*Check for valid parameter*/
If LEN(@txtBidderID) =0 or ISNULL(@txtBidderID,'') =''
RAISERROR(50002,10, 1,'Error Accessing Bidder Record - Must Provide Bidder ID')
ELSE
SELECT
Supplier.Name1,
Supplier.Name2,
Supplier.Name3,
Supplier.Name4,
Supplier.ID,
Supplier.StreetAddress,
Supplier.City,
Supplier.ProvinceState
FROM [dbo].Supplier
WHERE
(Supplier.Name1 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Supplier.Name2 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Supplier.Name3 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Supplier.Name4 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Supplier.PoBox LIKE '%' + @txtPOBox + '%' OR @txtPOBox IS NULL)
AND (Supplier.StreetAddress LIKE '%' + @txtAddress + '%' OR @txtAddress IS NULL)
AND (Supplier.City LIKE '%' + @ddlCity + '%' OR @ddlCity IS NULL)
AND (Supplier.District LIKE '%' + @txtDistrict + '%' OR @txtDistrict IS NULL)
AND (Supplier.ProvinceState LIKE '%' + @ddlProvince + '%' OR @ddlProvince IS NULL)
AND (Supplier.PostalCodeZipCode LIKE '%' + @txtPostalZC + '%' OR @txtPostalZC IS NULL)
AND (Supplier.id LIKE '%' + @txtSupplier + '%' OR @txtSupplier IS NULL)
AND (Supplier.notes LIKE '%' + @txtBidderNotes + '%' OR @txtBidderNotes IS NULL)
UNION
SELECT
Bidder.Name1,
Bidder.Name2,
Bidder.Name3,
Bidder.Name4,
Bidder.ID,
Bidder.StreetAddress,
Bidder.City,
Bidder.ProvinceState
FROM [dbo].Bidder
WHERE
(Bidder.Name1 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Bidder.Name2 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Bidder.Name3 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Bidder.Name4 LIKE '%' + @txtName + '%' OR @txtName IS NULL)
AND (Bidder.PoBox LIKE '%' + @txtPOBox + '%' OR @txtPOBox IS NULL)
AND (Bidder.StreetAddress LIKE '%' + @txtAddress + '%' OR @txtAddress IS NULL)
AND (Bidder.City LIKE '%' + @ddlCity + '%' OR @ddlCity IS NULL)
AND (Bidder.District LIKE '%' + @txtDistrict + '%' OR @txtDistrict IS NULL)
AND (Bidder.ProvinceState LIKE '%' + @ddlProvince + '%' OR @ddlProvince IS NULL)
AND (Bidder.PostalCodeZipCode LIKE '%' + @txtPostalZC + '%' OR @txtPostalZC IS NULL)
AND (Bidder.Notes LIKE '%' + @txtBidderNotes + '%' OR @txtBidderNotes IS NULL)
AND (Bidder.status LIKE '%' + @ddlBidderStatus + '%' OR @ddlBidderStatus IS NULL)
有人能告诉我为什么会收到此错误吗?
Msg 18054,Level 16,State 1,Procedure SPM_GetBidderSupplier,Line 30
错误50002,严重性10,状态1被引发,但在sys.messages中找不到具有该错误号的消息。如果错误大于50000,请确保使用sp_addmessage添加用户定义的消息。
对我来说没有意义,根据一些博客,10之前的任何严重程度都不是真的错误?这是真的?任何帮助,将不胜感激。感谢
答案 0 :(得分:0)
错误是由于下面的行显然是因为您将@txtBidderID传递为NULL -
/*Check for valid parameter*/
If LEN(@txtBidderID) =0 or ISNULL(@txtBidderID,'') =''
RAISERROR(50002,10, 1,'Error Accessing Bidder Record - Must Provide Bidder ID')