'ADD_MONTHS' 在 Derby 数据库中未被识别为函数或过程

'ADD_MONTHS' is not recognized as a function or procedure in Derby Database

我使用 Derby 数据库创建了 table

CREATE TABLE PROJECT
(PID  INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
PSDATE DATE,
PDURATION INTEGER,
PEDATE DATE,
PRIMARY KEY (PID)
);

我试图更新此项目的结束日期 table,将持续时间添加到开始日期

UPDATE PROJECT
SET PEDATE = ADD_MONTHS (PROJECT.PSDATE, PROJECT.PDURATION)
WHERE PID = PROJECT.PID;

但是我遇到了以下错误

"[Exception, Error code 30,000, SQLState 42Y03] 'ADD_MONTHS' is not recognized as a function or 
 procedure.
 Line 1, column 1"

在此先感谢帮我解决这个问题

你需要标记你的数据库,在mysql你可以这样做:

UPDATE PROJECT
SET PEDATE = DATEADD (PROJECT.PSDATE, interval PROJECT.PDURATION month)
WHERE PID = PROJECT.PID;

在 postgresql 中:

UPDATE PROJECT
SET PEDATE = PROJECT.PSDATE + interval '1 month' * PROJECT.PDURATION
WHERE PID = PROJECT.PID;

作为更新查询,这在 Derby 中有效。

  UPDATE PROJECT 
  SET PEDATE = DATE( {fn TIMESTAMPADD(SQL_TSI_MONTH, PDURATION, PSDATE)} );