1
這就是PostgreSQL: Inserting into a View made from two tablesPostgreSQL的:不能指在新的內部查詢規則中的
一個跟進的問題,我已經改變了我的原則是這樣:
CREATE RULE Insert_Post AS ON INSERT TO abcd1234.Posts DO INSTEAD
(
WITH Temp AS
(
INSERT INTO abcd1234.Ratable_Entity VALUES
(NEW.Id, NEW.User_Id, NEW.Publish_Date)
RETURNING Id
)
INSERT INTO abcd1234.Post
(SELECT Id, NEW.Title, NEW.Content FROM Temp)
);
但是現在我gettint出現以下錯誤:
ERROR: cannot refer to NEW within WITH query
有什麼辦法可以做到這一點嗎?我也試過RETURNING Id INTO temp_id
沒有WITH
,但得到了語法錯誤。