Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Help with SQL Server stored procedure
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Anacrusis
Junior Member

USA
219 Posts

Posted - 29 January 2003 :  08:27:04  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
I have a stored procedure with no input paramaters and 3 output paramaters. Whenever I try and execute the sp it says that my OUTPUT parameter needs a value.

CREATE PROCEDURE [inetclubhouse].[GetRandomQuote]
@RetQuoteID int OUTPUT,
@RetQuoteText varchar(300) OUTPUT,
@RetQuoteAuthor varchar(50) OUTPUT
AS
...

when executed this is what I get...
Procedure 'GetRandomQuote' expects parameter '@RetQuoteID', which was not supplied.

@RetQuoteID is an output paramater! why is it expecting me to pass a value to it?

The Internet ClubHouse
www.internet-clubhouse.com

Edited by - ruirib on 29 January 2003 09:19:47

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 29 January 2003 :  08:59:27  Show Profile
if you are executing it from Query Analyzer you need to pass in empty values ie....

declare
@RetQuoteID int,
@RetQuoteText varchar(300),
@RetQuoteAuthor varchar(50)

EXEC GetRandomQuote @RetQuoteID, @RetQuoteText, @RetQuoteAuthor

PRINT @RetQuoteID
PRINT @RetQuoteText
PRINT @RetQuoteAuthor

The UK MkIVs Forum
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 January 2003 :  09:26:44  Show Profile  Send ruirib a Yahoo! Message
How are you executing the sproc?


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Anacrusis
Junior Member

USA
219 Posts

Posted - 29 January 2003 :  09:31:58  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
through query anaylyzer using the exec command.

David, are you saying that when i execute the procedure from within my asp page that I won't need to pass 'dummy' values?

The Internet ClubHouse
www.internet-clubhouse.com
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 29 January 2003 :  09:58:15  Show Profile
No you still need to provide the ADO Params
Take this function as an example

	
Sub Details(byval LinkID, byref Company, byref About, byref Url, byref ImagePathSmall, _
					byref ImagePath, byref IsPremium)
	
       dim oComm	'as adodb.command
		
	set oComm = Server.CreateObject("ADODB.Command")
	with oComm
		.ActiveConnection = strConnString
		.CommandText = PROC_LINK_DETAILS
		.CommandType = adCmdStoredProc 
		.Parameters.Append .CreateParameter(PARAM_LINKID, adInteger, adParamInput, 4, LinkID)           
		.Parameters.Append .CreateParameter(PARAM_LINK_COMPANY, adVarChar, adParamOutput, 250)
		.Parameters.Append .CreateParameter(PARAM_LINK_ABOUT, adVarChar, adParamOutput, 7500) 
		.Parameters.Append .CreateParameter(PARAM_LINK_URL, adVarChar, adParamOutput, 250)           
		.Parameters.Append .CreateParameter(PARAM_LINK_IMAGEPATHSMALL, adVarChar, adParamOutput, 100)
		.Parameters.Append .CreateParameter(PARAM_LINK_IMAGEPATH, adVarChar, adParamOutput, 100)
		.Parameters.Append .CreateParameter(PARAM_LINK_ISPREMIUM, adBoolean, adParamOutput, 1)
		.Execute
	end with		
	Company = oComm.Parameters(PARAM_LINK_COMPANY).Value
	About = oComm.Parameters(PARAM_LINK_ABOUT).Value
	Url = oComm.Parameters(PARAM_LINK_URL).Value
	ImagePathSmall = oComm.Parameters(PARAM_LINK_IMAGEPATHSMALL).Value
	ImagePath = oComm.Parameters(PARAM_LINK_IMAGEPATH).Value
	IsPremium = oComm.Parameters(PARAM_LINK_ISPREMIUM).Value
	set oComm = nothing 	
	
End Sub


This passes in one value and returns 5
Notice the Parameters, 1 is adParamInput and 5 are adParamOutput

Sorry, 6 are output, not 5

The UK MkIVs Forum

Edited by - DavidRhodes on 29 January 2003 09:59:35
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 January 2003 :  10:01:50  Show Profile  Send ruirib a Yahoo! Message
quote:
Originally posted by Anacrusis

through query anaylyzer using the exec command.


I'd also like to know the specific syntax used.


Snitz 3.4 Readme | Like the support? Support Snitz too

Edited by - ruirib on 29 January 2003 10:02:29
Go to Top of Page

Anacrusis
Junior Member

USA
219 Posts

Posted - 29 January 2003 :  10:13:34  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
just simply 'exec GetRandomQuote'

It doesn't need any input paramaters and will return 3 different values. I would just return a recordset, but the sp needs to do some proccessing before it returns the results.

The Internet ClubHouse
www.internet-clubhouse.com
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 January 2003 :  10:28:32  Show Profile  Send ruirib a Yahoo! Message
But if you do have output parameters, you need to provide variables to receive the output values:


DECLARE @MyRetQuoteID int, @MyRetQuoteText varchar(300), @MyRetQuoteAuthor varchar(50)

EXEC GetRandomQuote @MyRetQuoteID OUTPUT, @MyRetQuoteText OUTPUT, @MyRetQuoteAuthor OUTPUT

Also you need to use the OUTPUT keyword to have the output values associated with your variables.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Anacrusis
Junior Member

USA
219 Posts

Posted - 29 January 2003 :  11:19:11  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
Ok, I think I understand now. Thanks alot!

The Internet ClubHouse
www.internet-clubhouse.com
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 January 2003 :  11:25:26  Show Profile  Send ruirib a Yahoo! Message
You're welcome.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07