SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Output parameter problem in sql server store proce
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Indrajit
Starting Member

India
11 Posts

Posted - 06/15/2012 :  01:40:40  Show Profile  Reply with Quote
Hi all
I am using SQL server and I created a store procedure but I am getting following error

<pre lang="vb">Server: Msg 201, Level 16, State 4, Procedure SP_New_OrderNo, Line 0
Procedure 'SP_New_OrderNo' expects parameter '@ERROR', which was not supplied.</pre>

Can any one please help me?

Bellow I am giving my Sore procedure

<pre lang="sql">CREATE PROCEDURE SP_New_OrderNo @CustomerNo NVARCHAR(10), @ModelNo NVARCHAR(10), @ERROR VARCHAR(100)OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CusNo NVARCHAR(50)
DECLARE @MdlNo NVARCHAR(50)
SELECT @CusNo=CustomerNo, @MdlNo=ModelNo FROM TblSerialNo WHERE CustomerNo=@CustomerNo
IF @CusNo=@CustomerNo
BEGIN
IF @MdlNo=@ModelNo
BEGIN
SET @ERROR = 'THIS CUSTOMER NO. AND MODEL NO. IS IN DATABASE PLEASE ENTER SERIAL NUMBER'
END
ELSE
BEGIN
SET @ERROR = 'THIS CUSTOMER NO. IS IN DATABASE PLEASE ENTER MODELNO AND SERIAL NUMBER'
END
END
ELSE
BEGIN
SET @ERROR = 'PLEASE ENTER CUSTOMER NO.'
INSERT INTO TblSerialNo (CustomerNo, ModelNo) VALUES (@CustomerNo, @ModelNo)
END

END

GO

EXEC SP_New_OrderNo '111','123'</pre>

Thanks To all

IndrajitDasgupta

jackv
Flowing Fount of Yak Knowledge

United Kingdom
1765 Posts

Posted - 06/15/2012 :  01:57:45  Show Profile  Visit jackv's Homepage  Reply with Quote
Output parameters behave similat to INPUT parameters. You need to specify the @Error in the EXEC.
EXEC SP_New_OrderNo '111','123',<place parameter> OUTPUT

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 06/15/2012 :  15:59:56  Show Profile  Reply with Quote
usually way to do this is to return integer codes from procedure using RETURN statements. Then in front end application there will logic to capture return value and set appropriate error message to be diplayed to the user.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000