從this earlier question繼續我在PostgreSQL 8.4上,並且在更新視圖時遇到問題。GeoServer不會寫入我的PostgreSQL可更新視圖
我有一個觀點:
CREATE VIEW filedata_view
AS SELECT num, id, ST_TRANSFORM(the_geom,900913) AS the_geom
FROM filedata
並希望從我的應用程序拋出利用Geoserver更新。但出現錯誤:
<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
<ServiceException> {http://www.opengeospatial.net/cite}filedata_view is read-only </ServiceException>
</ServiceExceptionReport>
因此PostgresSql中的視圖是不可更新的。我需要創建一個規則或觸發器來更新視圖。
我嘗試這樣做:
CREATE OR REPLACE RULE ins_view_2 AS
ON UPDATE TO filedata_view DO INSTEAD UPDATE filedata SET the_geom=ST_TRANSFORM(NEW.the_geom,70066)
WHERE num=NEW.num
,但它並沒有幫助,我仍然得到同樣的錯誤。
哪裏是我的錯?
1)請添加表格定義和一些數據到您的問題。 2)我似乎忘記了更新中的id字段(是FK ...?)3)您還應該爲插入和刪除案例創建規則。 4)錯誤來源於你的框架,它檢查目錄並得出結論:filedata_view是一個視圖(並且認爲視圖是RO),首先嚐試從命令行調用它。 5)總是在規則中使用完全限定的名字(例如:'where fd.num = NEW.num') – wildplasser 2012-07-27 07:39:24