create procedure myProc( @no char(20) )
as
DECLARE @RC INT
begin
insert into mytable( no ) values( @no )
if ( @@ERROR <> 0 )
SELECT @RC=-1
return @RC
end
go
as
DECLARE @RC INT
begin
insert into mytable( no ) values( @no )
if ( @@ERROR <> 0 )
SELECT @RC=-1
return @RC
end
go
仍是没有执行下面的错误处理语句
as
declare @rtt char(1)
begin
if not exists (select * from sysusers where name = 'mytable')
set @rtt ='A'
else
begin
insert into mytable( no ) values( @no )
set @rtt ='B'
end
return @rtt
go
IF @@ROWCOUNT = 0
return -1
as
begin TRAN
if NOT exists (select * from sysobjects where id = object_id(N'[mytable]') and OBJECTPROPERTY(id, N'IsTABLE') = 1)
GOTO ERRORFLAG
insert into mytable( no ) values( @no )
if ( @@ERROR <> 0 ) GOTO ERRORFLAG
COMMIT TRAN
RETURN 0ERRORFLAG:
ROLLBACK TRAN
return -1
go
create procedure myProc( @no char(20) ='')
as
begin TRAN
if NOT exists (select * from sysobjects where id = object_id(N'[mytable]') and OBJECTPROPERTY(id, N'IsTABLE') = 1)
GOTO ERRORFLAG
insert into mytable( no ) values( @no )
if ( @@ERROR <> 0 ) GOTO ERRORFLAG
COMMIT TRAN
RETURN 0ERRORFLAG:
ROLLBACK TRAN
return -1
go