我正在尝试编写一个触发器和一个更新namespace FoodOrderingApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void btnRegister_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(RegisterPage));
}
}
表的函数。触发器必须仅在包含常规'的新值时才会拍摄。在pricing
列插入/更新:
offer
问题: 当我运行此查询时:
drop trigger if exists reduced_offer on pricing;
drop function if exists offer_f();
create or replace function offer_f() returns trigger as $$
begin
if (new.title, new.publisher,new.offer) in --the offer already EXISTS
(select title, publisher, offer
from pricing)
then
raise notice 'exists';
update pricing
set price=new.price*0.9
where title=new.title and publisher=new.publisher and period=new.period;
else --the offer does NOT EXIST
raise notice 'not exists';
insert into pricing values
(new.title, new.publisher, 'renew', new.period, new.price*0.9);
end if;
return null;
end $$ language plpgsql;
create trigger reduced_offer
after insert or update
on pricing
for each row
when (new.offer='regular')
execute procedure offer_f();
当我确定此条目不在insert into pricing values ('Nature', 'UCLA', 'regular', 9900, 20);
表中时,我得到堆栈溢出错误和ENDLESS输出(超过20000行):
通知:存在
通知:存在
CONTEXT:SQL语句"更新定价
pricing
period = new.period
并提供='常规'"
PL / pgSQL函数offer_f()在SQL语句第8行
通知:存在
CONTEXT:SQL语句"更新定价
set price=new.price*0.9 where title=new.title and publisher=new.publisher and
period = new.period
依旧......
知道什么会导致这种溢出吗?