在Postgresql 9中,在另一个字段的值更改时自动更新一个字段中的值

在Postgresql 9中,在另一个字段的值更改时自动更新一个字段中的值

问题描述:

大家好
我有字段date_lastupdate,peiodicity(数据类型为时间间隔),due_date.
我想做的是
当date_lastupdate更改时,定期(每行可能不同),due_date字段将通过以下公式进行更新
due_date = date_lastupdate +定期

当我向
查询时

hi all
i have fields date_lastupdate,peiodicity(data type is interval),due_date.
What i''m trying to do is
when the date_lastupdate changes ,periodicity(which may be different for each row),due_date field gets updated by following formula
due_date=date_lastupdate+periodicity

when i queried with

select areaName,due_date from updation where due_date=date_lastupdate+periodicity




我只得到areaName,due_date列,没有任何记录...
请帮助我

在此先感谢

帕特尔
感谢thanx
这是我的输入错误
我跟你说的一样
但只返回没有记录的列名.




I get only columns areaName,due_date with no records...
plz help me

Thanks in advance

Hi patel
thanx for replying
it was my typing error
i did the same as u told
but only the column names with no records were returned.

尝试一下此操作
Try this
select areaName,due_date from updation where due_date=date_lastupdate+periodicity



为什么使用due_date=due_date+periodicity?



Why do you use due_date=due_date+periodicity?


如果尝试更改due_date字段,则应使用 ^ ]语句.
If you are trying change the due_date field you should be using an update[^] statement.