SQL Server stored prcedures with output parameters

Steve Holden steve at holdenweb.com
Thu Nov 18 03:13:37 EST 2004


Steve Holden wrote:

> 
> Hmmm, following up, added another test to adodbapi to retrieve a value 
> from a table into an output parameter it works, so this puts the 
> suspicion on to the stored procedure. Since this was written by the 
> client I'll take a look at it later (when I'm back in the office) and 
> see what the problem might be.
> 
> happily-talking-away-to-myself-ly y'rs  - steve

However, the stored procedure below appears to consistently return zero 
for the link_id when called with:

columnist_id, url, title, description, link_id = \
	curs.callproc("sp_InsertArticle",
		(columnist_id, url, title, description, 0))

so maybe there really *is* something wrong. Or, hopefully, I'm just 
making a simple mistake in the calls? Whatever value is used as the 
fifth (output) parameter seems to get returned, despite the apparent 
change in the stored procedure.

Create PROCEDURE dbo.sp_InsertArticle
(
	@columnist_id int,
	@url varchar(255),
	@title varchar(99),
	@description text,
    	@link_id int OUTPUT
)
AS
BEGIN
	INSERT INTO link	(columnist_id,url,title,description)
	VALUES (@columnist_id, at url, at title, at description)

     SELECT @link_id = @@IDENTITY
END

GO

not-quite-so-happi-ly y'rs  - steve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119



More information about the Python-list mailing list