这个RETURN 只是返回不往下执行。没有返回值。如果insert成不成功没有判断,可以加
if @@error <> 0
begin
RAISERROR (' err ', 16, 1)
return -1
end
return值可以在前台获取。
create procedure up_a
@id char(1) = null
as
If @id = '1'
return 1
else
return 0
godeclare @id int
select @id = up_a ('0')
print @id
if @@error <> 0
begin
RAISERROR (' err ', 16, 1)
return -1
end
return值可以在前台获取。
create procedure up_a
@id char(1) = null
as
If @id = '1'
return 1
else
return 0
godeclare @id int
select @id = up_a ('0')
print @id
if exists (select name from sysobjects where name = 'p_inst_tzhxx' and type ='P')
drop procedure p_inst_tzhxx
go
create procedure p_inst_tzhxx
@m_dwmc varchar(50) = null,
@m_lxdh char(13) = null,
@m_dwdz varchar(50) = null,
@m_xq char(12) = null,
@m_lb char(30) = null
as
insert into T_ZHXX
(dwmc,lxdh,dwdz,xq,lb)
values (@m_dwmc,@m_lxdh,@m_dwdz,@m_xq,@m_lb)
return @@Error
go
返回错误代码,0表示成功调用方法如 weixy() 所说
use bjdb
if exists (select name from sysobjects where name = 'p_inst_tzhxx' and type ='P')
drop procedure p_inst_tzhxx
go
create procedure p_inst_tzhxx
@m_dwmc varchar(50) = null,
@m_lxdh char(13) = null,
@m_dwdz varchar(50) = null,
@m_xq char(12) = null,
@m_lb char(30) = null
as
declare @rc int,@lerror int
select @rc=0
select @lerror=0
if @rc=0
begin
insert into T_ZHXX
(dwmc,lxdh,dwdz,xq,lb)
values (@m_dwmc,@m_lxdh,@m_dwdz,@m_xq,@m_lb)
select @lerror=@@error
if @lerror<>0
begin
select @rc=-1000
return @rc
end
end
go