P********R 发帖数: 1691 | 1 得到一出错信息如下
Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0
Procedure or function AddLineItem has too many arguments specified.
/* EXECUTE代码如下:*/
EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT;
IF @vStr = 'Insert failed'
BEGIN
PRINT 'Insert failed'
PRINT 'FAILURE';
RETURN;
END;
ELSE
PRINT 'Insert successed!'
-- ENDIF;
PRINT 'SUCCESS.';
END;
/* the AddLineItem代码如下: */
IF EXISTS (SELECT name FROM SYSOBJECTS WHERE name = 'AddLineItem')
BEGIN DROP PROCEDURE AddLineItem; END;
GO
CREATE PROCEDURE AddLineItem --[with orderid, partid and qty input
parameters]
@vOrderid SMALLINT,
@vPartid SMALLINT,
@vQty SMALLINT,
@vFound CHAR(16) OUTPUT
AS
DECLARE @vNewDetail SMALLINT;
BEGIN
BEGIN TRANSACTION -- this is the only BEGIN TRANSACTION for the lab
assignment
EXECUTE GetNewDetail @vOrderid, @vNewDetail OUTPUT;
INSERT INTO ORDERITEMS (orderid, detail, partid, qty)
VALUES (@vOrderid, @vNewDetail, @vPartid, @vQty);
-- your error handling
IF @@ERROR <> 0
BEGIN
SET @vFound = 'Insert failed';
PRINT 'The data insert failed.';
ROLLBACK TRANSACTION;
END;
ELSE
BEGIN
SET @vFound = 'Insert succedded';
PRINT 'The data insert successed.'
COMMIT TRANSACTION;
END;
-- END IF;
-- END TRANSACTION;
END;
请问是哪个定义变量错了(多了)?谢谢! | i****a 发帖数: 36252 | 2 try:
declare @vOrderid ....
set @vOrderid = ....
EXECUTE AddlineItem @vOrderid = @vOrderid, @vPartid = @vPartid, @vQty = @
vQty, @vStr OUTPUT;
【在 P********R 的大作中提到】 : 得到一出错信息如下 : Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0 : Procedure or function AddLineItem has too many arguments specified. : /* EXECUTE代码如下:*/ : EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT; : IF @vStr = 'Insert failed' : BEGIN : PRINT 'Insert failed' : PRINT 'FAILURE'; : RETURN;
| s**********o 发帖数: 14359 | 3 主要还是@vStr没定义吧,
另外搞一个@MyvStr吧 | P********R 发帖数: 1691 | 4 @vStr在最前面就定义了的,总共有好几个EXECUTE,这个出问题的EXECUTE是最后一个。
【在 s**********o 的大作中提到】 : 主要还是@vStr没定义吧, : 另外搞一个@MyvStr吧
| P********R 发帖数: 1691 | 5 最前面是这样的:
CREATE PROCEDURE Sampleproc
@vCustid SMALLINT,
@vOrderid SMALLINT,
@vPartid SMALLINT,
@vQty SMALLINT
AS
DECLARE @vStr CHAR(128)
BEGIN
EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT;
IF @vStr = 'Insert failed'
BEGIN
PRINT 'Insert failed'
PRINT 'FAILURE';
RETURN;
END;
ELSE
PRINT 'Insert successed!'
-- ENDIF;
PRINT 'SUCCESS.';
END; | i****a 发帖数: 36252 | 6 what is in GetNewDetail ?
【在 P********R 的大作中提到】 : 最前面是这样的: : CREATE PROCEDURE Sampleproc : @vCustid SMALLINT, : @vOrderid SMALLINT, : @vPartid SMALLINT, : @vQty SMALLINT : AS : DECLARE @vStr CHAR(128) : BEGIN : EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT;
| i****a 发帖数: 36252 | 7 did you get this error from SQL? what version of SQL?
【在 P********R 的大作中提到】 : 最前面是这样的: : CREATE PROCEDURE Sampleproc : @vCustid SMALLINT, : @vOrderid SMALLINT, : @vPartid SMALLINT, : @vQty SMALLINT : AS : DECLARE @vStr CHAR(128) : BEGIN : EXECUTE AddlineItem @vOrderid, @vPartid, @vQty, @vStr OUTPUT;
| P********R 发帖数: 1691 | 8 IF EXISTS (SELECT name FROM SYSOBJECTS WHERE name = 'GetNewDetail')
BEGIN DROP PROCEDURE GetNewDetail; END;
GO
CREATE PROCEDURE GetNewDetail
@vOrderid SMALLINT,
@vNewDetail SMALLINT OUTPUT
AS
BEGIN
SELECT @vNewDetail = MAX(ISNULL((detail), 0)) + 1
FROM ORDERITEMS
WHERE orderid = @vOrderid;
END;
【在 i****a 的大作中提到】 : what is in GetNewDetail ?
|
| P********R 发帖数: 1691 | 9 Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0
Procedure or function AddLineItem has too many arguments specified.
Microsoft SQL Server Management Studio 2008
【在 i****a 的大作中提到】 : did you get this error from SQL? what version of SQL?
| i****a 发帖数: 36252 | 10 EXECUTE GetNewDetail @vOrderid, @vNewDetail OUTPUT;
试过, 有错误吗?
【在 P********R 的大作中提到】 : IF EXISTS (SELECT name FROM SYSOBJECTS WHERE name = 'GetNewDetail') : BEGIN DROP PROCEDURE GetNewDetail; END; : GO : CREATE PROCEDURE GetNewDetail : @vOrderid SMALLINT, : @vNewDetail SMALLINT OUTPUT : AS : BEGIN : SELECT @vNewDetail = MAX(ISNULL((detail), 0)) + 1 : FROM ORDERITEMS
| | | i****a 发帖数: 36252 | 11 did you try this?
EXECUTE AddlineItem @vOrderid = @vOrderid, @vPartid = @vPartid, @vQty = @
vQty, @vStr OUTPUT;
【在 P********R 的大作中提到】 : Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0 : Procedure or function AddLineItem has too many arguments specified. : Microsoft SQL Server Management Studio 2008
| P********R 发帖数: 1691 | 12 试过,没错。
【在 i****a 的大作中提到】 : EXECUTE GetNewDetail @vOrderid, @vNewDetail OUTPUT; : 试过, 有错误吗?
| P********R 发帖数: 1691 | 13 试了,同样的错误。
Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0
Procedure or function AddLineItem has too many arguments specified.
【在 i****a 的大作中提到】 : did you try this? : EXECUTE AddlineItem @vOrderid = @vOrderid, @vPartid = @vPartid, @vQty = @ : vQty, @vStr OUTPUT;
| i****a 发帖数: 36252 | 14 is the AddlineItem on the server up to date?
【在 P********R 的大作中提到】 : 试了,同样的错误。 : Msg 8144, Level 16, State 2, Procedure AddLineItem, Line 0 : Procedure or function AddLineItem has too many arguments specified.
| P********R 发帖数: 1691 | 15 yes.
【在 i****a 的大作中提到】 : is the AddlineItem on the server up to date?
| i****a 发帖数: 36252 | 16 from management studio, right click on the stored procedure, and select
execute. provide required values and click ok. It will generate a script
with parameters populated
beware this actually executes the SP.
【在 P********R 的大作中提到】 : yes.
| P********R 发帖数: 1691 | 17 万分感谢!
我把@vStr去掉了,用@@ERROR<>0来判断有无错误,就通过了。
【在 i****a 的大作中提到】 : from management studio, right click on the stored procedure, and select : execute. provide required values and click ok. It will generate a script : with parameters populated : beware this actually executes the SP.
|
|