Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output

I have this stored procedure:

ALTER PROCEDURE spCertificationType 
    @result nvarchar(15) output,
    @mode int 
AS
BEGIN
    if @mode = 1
    begin
        exec spGeneratedID 2, @result output
        print @result
    end
END

but when I tried to execute it,it has this error

The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.

I tried to set @mode as output like this:

ALTER PROCEDURE spCertificationType 
    @result nvarchar(15) output,
    @mode int output
AS
BEGIN
    if @mode = 1
    begin
        exec spGeneratedID 2, @result output
        print @result
    end
END

but the it returns a null value.

Any fix for this? Thanks in advance.

like image 858
roger bulawan Avatar asked Aug 26 '15 06:08

roger bulawan


People also ask

Which mode is recommended for formal parameters of stored functions?

IN OUT mode: You can assign values to the formal parameter at runtime when using an IN OUT mode variable. At the conclusion of the function or procedure the internal variable's reference is passed to the calling program scope and replaces the original reference to the actual parameter.


1 Answers

the sequence of parameter in store procedure is that first use input parameter then use output parameter:- you can see this link for more knowledge of store procedure:-

http://www.codeproject.com/Articles/126898/Sql-Server-How-To-Write-a-Stored-Procedure-in-SQL

ALTER PROCEDURE spCertificationType 

     @mode int,
     @result nvarchar(15) output
 AS
 BEGIN
     if @mode = 1
   begin
    exec spGeneratedID 2, @result output
    print @result
   end
END
like image 192
david sam Avatar answered Sep 18 '22 22:09

david sam