我收到此错误。为什么呢?
CREATE OR REPLACE FUNCTION factuurRegel()
RETURNS TRIGGER AS
$$
BEGIN
INSERT INTO Factuur(factuurnr, factuurdatum, bestelnr)
VALUES ((default to_char(CURRENT_DATE ,'yyyy') || '-' || new.bestelnr), CURRENT_DATE, new.bestelnr);
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
错误:
ERROR: syntax error at or near "default"
LINE 7: VALUES ((default to_char(CURRENT_DATE ,'yyyy') || '-' || new...
^
********** Error **********
ERROR: syntax error at or near "default"
SQL state: 42601
Character: 137
答案 0 :(得分:2)
我不是一个postgresql人,但我99%肯定你不能把default
放在VALUES()
里面并且还包含一个值。我想你想要这个:
CREATE OR REPLACE FUNCTION factuurRegel()
RETURNS TRIGGER AS
$$
BEGIN
INSERT INTO Factuur(factuurnr, factuurdatum, bestelnr)
VALUES ((to_char(CURRENT_DATE ,'yyyy') || '-' || new.bestelnr), CURRENT_DATE, new.bestelnr);
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
See here for more info - 您可以将DEFAULT包含为值或提供值,但不能同时包含两者。