• 全部
  • 基础类
  • 应用实例
  • 新技术前沿

帮我看一下有什么问题没有

shankaipingo 残友软件有限公司 技术总监  2008-03-08 01:18:18
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON
GO





ALTER Proc [AddAGroup]
@Title NvarChar(50),
@AllowNoneApproval tinyInt,
@DomainName NvarChar(50),
@Description NvarChar(500),
@BgImage NvarChar(200),
@GroupRules NvarChar(500),
@SubTitle NvarChar(50),
@Logo NvarChar(200),
@creator NvarChar(50),
@creatorid Int,
@groupid Int Output
As




begin transaction
INSERT INTO [Group]
(
[Title],
[allowNoneApproval],
[DomainName],
[Description],
[bgImage],
[MemberCount],
[TopicCount],
[Hits],
[GroupRules],
[subTitle],
[Logo],
createDate
)

VALUES
(
@Title,
@allowNoneApproval,
@DomainName,
@Description,
@bgImage,
1,
0,
0,
@GroupRules,
@subTitle,
@Logo,
getdate()
)
if(@@error<>0)
begin
rollback transaction
return -1
end

Set @groupid=@@IDENTITY

INSERT INTO [GroupMember]
(
[UserId],
[GroupId],
[GroupMemberType],
[username]
)
VALUES
(
@creatorid,
@groupid,
1,
@creator
)


if(@@error<>0)
begin
rollback transaction
return -1
end

commit transaction
return @groupid


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

...全文
58 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
shankaipingo 2008-03-12
谢谢
回复
-狙击手- 2008-03-08
路过
回复
Limpire 2008-03-08
你这种情况不会
当然用我的写法更好一些
回复
shankaipingo 2008-03-08
这个会引出孤立事务吗???http://computer.stuun.cn/sanjikaoshi/shujuku/118572747137006_2.html,
看了这篇文章,我很害怕 
回复
shankaipingo 2008-03-08
谢就一个字!!
回复
Limpire 2008-03-08
回复
shankaipingo 2008-03-08
我的行不行?
回复
Limpire 2008-03-08
OUPUT参数不用RETURN。
RETURN是返回值,永远是整数。
回复
Limpire 2008-03-08
ALTER       Proc [AddAGroup]
@Title NvarChar(50),
@AllowNoneApproval tinyInt,
@DomainName NvarChar(50),
@Description NvarChar(500),
@BgImage NvarChar(200),
@GroupRules NvarChar(500),
@SubTitle NvarChar(50),
@Logo NvarChar(200),
@creator NvarChar(50),
@creatorid Int,
@groupid Int Output
As

SET XACT_ABORT ON

begin transaction
INSERT INTO [Group]
(
[Title],
[allowNoneApproval],
[DomainName],
[Description],
[bgImage],
[MemberCount],
[TopicCount],
[Hits],
[GroupRules],
[subTitle],
[Logo],
createDate
)

VALUES
(
@Title,
@allowNoneApproval,
@DomainName,
@Description,
@bgImage,
1,
0,
0,
@GroupRules,
@subTitle,
@Logo,
getdate()
)
/*
if(@@error<>0)
begin
rollback transaction
return -1
end
*/

Set @groupid=@@IDENTITY

INSERT INTO [GroupMember]
(
[UserId],
[GroupId],
[GroupMemberType],
[username]
)
VALUES
(
@creatorid,
@groupid,
1,
@creator
)

/*
if(@@error<>0)
begin
rollback transaction
return -1
end
*/

commit transaction
--return @groupid

SET XACT_ABORT OFF

GO
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-03-08 01:18
社区公告
暂无公告