PB前台插入数据的时候,有时候会出现:ROLLBACK TRANSACTION 请求没有对应的 BEGIN TRANSACTION。这个错误。。
是什么原因造成的?
代码如下。。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
goALTER TRIGGER [Tr_ctn_dynamic]
ON [dbo].[DT_Ctn_Dynamic]
AFTER INSERT,UPDATE
AS
BEGIN
SET NOCOUNT ON;
create table #ctn_dym(
id int identity(1,1),
Ctn_No varchar(20),
Main_Bl_No varchar(30),
Ie_Flag varchar(1),
Dynamic_Type varchar(40),
op_time varchar(20),
ef_flag varchar(1)
) --此处忽略部分变量声明---
declare @ctn_id int declare @rows int
set @ctn_id = 1
delete from #ctn_dym
insert into #ctn_dym(ctn_no,main_bl_no,ie_flag,dynamic_type,op_time,ef_flag)
select container_code,Main_Bl_No,ie_flag,dynamic_type,date_time,ef_flag from inserted
set @rows = @@rowcount
--开始循环
while @ctn_id <= @rows
begin
select @ctn_no = ctn_no,@op_time = op_time,@op_type = Dynamic_Type,@bl = main_bl_no,@ef_flag = ef_Flag
from #ctn_dym where id = @ctn_id
select @last_op_time = op_time from hdfc_container where Container_no = @ctn_no
if @@rowcount = 1
begin
if @last_op_time < @op_time
begin
if @op_type = 'EE'
begin
set @cy_flag = 'O'
set @country = 'CHN'
end
if @op_type = 'EI'
begin
set @cy_flag = 'I'
set @country = 'CHN'
end
update hdfc_container set op_type = @op_type,EF_FLAG = @EF_FLAG,country = @country , cy_flag = @cy_flag,op_time = @op_time ,
bl = @bl
where container_no = @ctn_no
end
end
set @CTN_ID = @ctn_id + 1 end
END
是什么原因造成的?
代码如下。。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
goALTER TRIGGER [Tr_ctn_dynamic]
ON [dbo].[DT_Ctn_Dynamic]
AFTER INSERT,UPDATE
AS
BEGIN
SET NOCOUNT ON;
create table #ctn_dym(
id int identity(1,1),
Ctn_No varchar(20),
Main_Bl_No varchar(30),
Ie_Flag varchar(1),
Dynamic_Type varchar(40),
op_time varchar(20),
ef_flag varchar(1)
) --此处忽略部分变量声明---
declare @ctn_id int declare @rows int
set @ctn_id = 1
delete from #ctn_dym
insert into #ctn_dym(ctn_no,main_bl_no,ie_flag,dynamic_type,op_time,ef_flag)
select container_code,Main_Bl_No,ie_flag,dynamic_type,date_time,ef_flag from inserted
set @rows = @@rowcount
--开始循环
while @ctn_id <= @rows
begin
select @ctn_no = ctn_no,@op_time = op_time,@op_type = Dynamic_Type,@bl = main_bl_no,@ef_flag = ef_Flag
from #ctn_dym where id = @ctn_id
select @last_op_time = op_time from hdfc_container where Container_no = @ctn_no
if @@rowcount = 1
begin
if @last_op_time < @op_time
begin
if @op_type = 'EE'
begin
set @cy_flag = 'O'
set @country = 'CHN'
end
if @op_type = 'EI'
begin
set @cy_flag = 'I'
set @country = 'CHN'
end
update hdfc_container set op_type = @op_type,EF_FLAG = @EF_FLAG,country = @country , cy_flag = @cy_flag,op_time = @op_time ,
bl = @bl
where container_no = @ctn_no
end
end
set @CTN_ID = @ctn_id + 1 end
END
是什么原因造成的?
提示很明显了吧,没有对应的BEGIN TRAN ,检查是否有嵌套的事务,
可能你PB里面有对写在这个触发器里面的表(除去DT_Ctn_Dynamic)操作。自己检查一下是否操作完成以后没有commit;