C
cjj2
Unregistered / Unconfirmed
GUEST, unregistred user!
CREATE PROCEDURE Gp_InsertA
(
@Parid [varchar](25),
@DbName [varchar](30),
@szFlag [char](2),
@UserCode [varchar](26),
@FullName [varchar](66),
@Name [varchar](30),
@Total00 [numeric](18,4),
@Comment [varchar](256),
@PinYinCode [varchar](66)
)
AS
declare @nReturntype int,@EtypeId_1 [varchar](25),@nSoncount int,@nSonnum int,@leveal smallint
exec @nReturntype=Gp_createId @ParId,@dbname,@EtypeId_1 out,@nSonnum out,@nSoncount out
if @nReturntype=-1 return -1
if @nReturntype=-2 return -2
select * from [atype]
where typeId=@EtypeId_1 --or usercode=@usercode and deleted<>1
if @@Rowcount<>0
begin
-- print '商品已存在'+@etypeid_1
return -3
end
begin tran insertproc
select @leveal=leveal from atype where typeid=@Parid
select @leveal=@leveal+1
INSERT INTO [atype]
( [typeId],
[Parid],
[leveal],
[soncount],
[sonnum],
[FullName],
[Name],
[UserCode],
[total00],
[sysflag],
[Comment],
[PinYinCode]
)
VALUES
( @EtypeId_1,
@Parid,
@leveal,
0,
0,
@FullName,
@Name,
@UserCode,
@Total00,
@szFlag,
@Comment,
@PinYinCode
)
if @@rowcount=0
begin
rollback tran insertproc
return -1
end else
begin
update [atype]
set sonnum=@nSonnum+1,soncount=@nSoncount+1
where typeid=@Parid
end
commit tran insertproc
越详细越好!
另外问一个问题:存储过程中的set nocount on是什么意思?
(
@Parid [varchar](25),
@DbName [varchar](30),
@szFlag [char](2),
@UserCode [varchar](26),
@FullName [varchar](66),
@Name [varchar](30),
@Total00 [numeric](18,4),
@Comment [varchar](256),
@PinYinCode [varchar](66)
)
AS
declare @nReturntype int,@EtypeId_1 [varchar](25),@nSoncount int,@nSonnum int,@leveal smallint
exec @nReturntype=Gp_createId @ParId,@dbname,@EtypeId_1 out,@nSonnum out,@nSoncount out
if @nReturntype=-1 return -1
if @nReturntype=-2 return -2
select * from [atype]
where typeId=@EtypeId_1 --or usercode=@usercode and deleted<>1
if @@Rowcount<>0
begin
-- print '商品已存在'+@etypeid_1
return -3
end
begin tran insertproc
select @leveal=leveal from atype where typeid=@Parid
select @leveal=@leveal+1
INSERT INTO [atype]
( [typeId],
[Parid],
[leveal],
[soncount],
[sonnum],
[FullName],
[Name],
[UserCode],
[total00],
[sysflag],
[Comment],
[PinYinCode]
)
VALUES
( @EtypeId_1,
@Parid,
@leveal,
0,
0,
@FullName,
@Name,
@UserCode,
@Total00,
@szFlag,
@Comment,
@PinYinCode
)
if @@rowcount=0
begin
rollback tran insertproc
return -1
end else
begin
update [atype]
set sonnum=@nSonnum+1,soncount=@nSoncount+1
where typeid=@Parid
end
commit tran insertproc
越详细越好!
另外问一个问题:存储过程中的set nocount on是什么意思?