在Sql Server trigger中使用if条件句总报错 10
useTPCHgocreatetriggerIN_SERTonLineitemafterinsertas源码如下,想要在Lineitem表格中增加一项订单明细时,自动修改...
use TPCH
go
create trigger IN_SERT
on Lineitem
after insert
as
源码如下,想要在Lineitem表格中增加一项订单明细时,自动修改订单Orders的TotalPrice。
create trigger IN_SERT
on Lineitem
after insert
as
if (Orders.Orderkey = inserted.Orderkey )
begin
update Orders
set Orders.Totalprice = Orders.Totalprice
+ inserted.Extendeprice*(1-inserted.Discount) * (1+inserted.Tax)
- deleted.Extendedprice * (1-deleted.Discount) * (1+deleted.Tax)
select *
from Orders,inserted,deleted
end
else
begin
update Orders
set Orders.Totalprice = inserted.Extendeprice*(1-inserted.Discount) * (1+inserted.Tax)
select *
from Orders,inserted,deleted
end
然鹅总是报错
消息 4104,级别 16,状态 1,过程 IN_SERT,第 8 行
The multi-part identifier "Orders.Orderkey" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 8 行
The multi-part identifier "inserted.Orderkey" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Extendeprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Tax" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Extendedprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Tax" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Extendeprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Tax" could not be bound. 展开
go
create trigger IN_SERT
on Lineitem
after insert
as
源码如下,想要在Lineitem表格中增加一项订单明细时,自动修改订单Orders的TotalPrice。
create trigger IN_SERT
on Lineitem
after insert
as
if (Orders.Orderkey = inserted.Orderkey )
begin
update Orders
set Orders.Totalprice = Orders.Totalprice
+ inserted.Extendeprice*(1-inserted.Discount) * (1+inserted.Tax)
- deleted.Extendedprice * (1-deleted.Discount) * (1+deleted.Tax)
select *
from Orders,inserted,deleted
end
else
begin
update Orders
set Orders.Totalprice = inserted.Extendeprice*(1-inserted.Discount) * (1+inserted.Tax)
select *
from Orders,inserted,deleted
end
然鹅总是报错
消息 4104,级别 16,状态 1,过程 IN_SERT,第 8 行
The multi-part identifier "Orders.Orderkey" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 8 行
The multi-part identifier "inserted.Orderkey" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Extendeprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 12 行
The multi-part identifier "inserted.Tax" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Extendedprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 13 行
The multi-part identifier "deleted.Tax" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Extendeprice" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Discount" could not be bound.
消息 4104,级别 16,状态 1,过程 IN_SERT,第 22 行
The multi-part identifier "inserted.Tax" could not be bound. 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询