0

我有以下存储过程..

CREATE PROCEDURE USP_COM_MST_DEL(
    @Code AS INT = 0,
    @Name AS VARCHAR(50)= '',
    @Type AS INT =0,
    @Operation AS varchar(20) ='',
    @Message AS VARCHAR(200) OUTPUT,
    @Status AS VARCHAR(2) OUTPUT
)
AS
BEGIN
    IF(@Operation = 'DISPLAY')
    BEGIN
        IF NOT EXISTS (SELECT * FROM COM_MST WHERE COM_CTCD = @Type)
        BEGIN
            SET @Status = '0'
            SET @Message = 'NO RECORD FOUND'
        END
        ELSE
        BEGIN 
            SET @Status = '0'
            SET @Message = 'NO RECORD FOUND'
            SELECT * FROM COM_MST WHERE COM_CTCD = @Type
        END
    END
END

但是当我尝试运行该程序时..它显示错误

USP_COM_MST_DEL @Operation = 'DISPLAY'

错误:

过程或函数“USP_COM_MST_DEL”需要参数“@Message”,但未提供该参数。

4

2 回答 2

3

您需要指定输出参数的位置。

declare 
    @Message VARCHAR(200),
    @Status VARCHAR(2) 

exec USP_COM_MST_DEL @Operation = 'DISPLAY', @message output, @status output

(这正是错误消息所说的)

于 2013-09-04T11:18:14.893 回答
1

现在显示没有错误...

exec USP_COM_MST_DEL @Operation = 'DISPLAY',@type=4, @message ='', @status =''
于 2013-09-04T11:40:47.790 回答