BEGINSET NOCOUNT ON;if @_MODE NOT IN ('A','M','D') begin raiserror('參數錯誤!',16,3); return; end; declare @rowcount int,@error int; if @_MODE='A'begin in ...
BEGIN
SET NOCOUNT ON;
if @_MODE NOT IN ('A','M','D')
begin
raiserror('參數錯誤!',16,3);
return;
end;
declare @rowcount int,@error int;
if @_MODE='A'
begin
insert into szdxInfo (Id,Bh,[Name],nation) select
@Id,@Bh,@Name,
@Nation;
if @@error<>0 return;
end;
if @_MODE='M'
begin
update szdxInfo set [Name]=@Name,
nation=@Nation
where id=@id;
select @error=@@error,@rowcount=@@rowcount;
if @error<>0 return;
if @rowcount<>1
begin
raiserror('沒有修改記錄!!',16,3)
return;
end;
end;
if @_MODE='D'
begin
delete szdxInfo where Id=@id;
select @error=@@error,@rowcount=@@rowcount;
if @error<>0 return;
if @rowcount<>1
begin
raiserror('沒有刪除記錄!!',16,3)
return;
end;
end;
insert into ActionLog ([date],[userid],Computerid,
TableName,[Action]) select
getdate(),@_USERID,
@_COMPUTERID,
'szdxInfo',@_MODE;
/*
exec Update_szdxInfo @id='11',
@Name ='劉某某',
@Nation ='漢族',
@_MODE ='A',
@_USERID=1,
@_COMPUTERID=1
select * from szdxINfo
*/
END