W
wqxsdly
Unregistered / Unconfirmed
GUEST, unregistred user!
两个基表
create table sp
(
spbh char(12) not null, --商品编号
spmc varchar(20) null, --商品名称
primary key (spbh)
)
go
create table khdafl
(
dadh integer not null, --单号
xh integer not null, --序号
spbh char(12) not null, --商品编号
primary key (dadh,xh)
)
go
还有一个 View
create view v_khdafl
as
select kk.dadh,kk.xh,kk.spbh,sp.spmc from sp,khdafl kk where kk.spbh=sp.spbh
go
在v_khdafl 上建触发器
create trigger tr_v_khdafl_insert on v_khdafl instead of insert
as
insert into khdafl (dadh,xh,spbh)
select dadh,xh,spbh from inserted
go
delphi6 中
adodataset1.commandtext的值为 select dadh,xh,spbh,spmc from v_khdafl
然后,在adodataset1中添加纪录,保存出现错误:
原因是delphi自动向两个基表各添加一条纪录,这与sqlserver的instead of 触发器
就不一致了
请教各位高手:如果还想用触发器的话,该怎样解决此问题?万分感谢!
注:在sqlserver客户端查询分析器里向v_khdafl表里添加数据很正常
create table sp
(
spbh char(12) not null, --商品编号
spmc varchar(20) null, --商品名称
primary key (spbh)
)
go
create table khdafl
(
dadh integer not null, --单号
xh integer not null, --序号
spbh char(12) not null, --商品编号
primary key (dadh,xh)
)
go
还有一个 View
create view v_khdafl
as
select kk.dadh,kk.xh,kk.spbh,sp.spmc from sp,khdafl kk where kk.spbh=sp.spbh
go
在v_khdafl 上建触发器
create trigger tr_v_khdafl_insert on v_khdafl instead of insert
as
insert into khdafl (dadh,xh,spbh)
select dadh,xh,spbh from inserted
go
delphi6 中
adodataset1.commandtext的值为 select dadh,xh,spbh,spmc from v_khdafl
然后,在adodataset1中添加纪录,保存出现错误:
原因是delphi自动向两个基表各添加一条纪录,这与sqlserver的instead of 触发器
就不一致了
请教各位高手:如果还想用触发器的话,该怎样解决此问题?万分感谢!
注:在sqlserver客户端查询分析器里向v_khdafl表里添加数据很正常