boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Transact SQL问题请教
相关主题
问一个store procedure 问题
大家对 Transaction 是怎么看的?
SQL Server set implicit_transaction on
Why does this Stored procedure fail ?
why use anonymous block when calling stored procedure?
SQL server stored procedure 求助
求教:Oracle trigger 中生成的数据如何送到stored procedure中?
stored procedure running 很慢的问题
[转载] 真的没有人懂 ORACLE pro*c阿? :((((
How to let oracle execute a procedure every hour?
相关话题的讨论汇总
话题: end话题: begin话题: vorderid话题: insert
进入Database版参与讨论
1 (共1页)
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

相关主题
Why does this Stored procedure fail ?
why use anonymous block when calling stored procedure?
SQL server stored procedure 求助
求教:Oracle trigger 中生成的数据如何送到stored procedure中?
进入Database版参与讨论
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.

1 (共1页)
进入Database版参与讨论
相关主题
How to let oracle execute a procedure every hour?
how can i execute pl/sql (or stored procedure) in java??
how to include record deleted date into trigger?
T-SQL 问题
a Store Procedure question...
请教:'now' 的时间是怎么实现的
SSIS: execute SQL task failed on Insert statements
SQL Server怎么查为什么store procedure跑的慢?
Recompile SQL Server Store procedure
error of executing SQL query of string concatenation (转载
相关话题的讨论汇总
话题: end话题: begin话题: vorderid话题: insert