TRIGGER分割多边形

时间:2016-03-03 14:41:24

标签: oracle triggers

我有两张桌子:PLOT和ROAD。 每次我在ROAD上添加一个新的片段时,我想把我的多边形从与ROAD相交的PLOT中分开。

没有触发器就能正常工作。但如果我有下面的触发器,那么请求我在“绑定参数”窗口的“:new.GID”中输入一个值。

我确信我没有正确地写出扳机,你能帮帮我吗? Thanxs很多

DROP TRIGGER "PLOT";
CREATE OR REPLACE TRIGGER "PLOT"
BEFORE INSERT OR UPDATE ON "ROAD"
FOR EACH ROW
BEGIN

-- I insert in NEW_ROWS the result from the SDO_DIFFERENCE    
INSERT INTO "NEW_ROWS" ("GID","GEOM") AS
WITH TOTAL_PLOT AS (
SELECT c."GID", c."GEOM"
FROM "ROAD" T
JOIN "PLOT" c ON SDO_RELATE(c."GEOM", T."GEOM", 'mask=ANYINTERACT') = 'TRUE'
WHERE T."GID" = :new."GID"
)

SELECT a."GID", SDO_GEOM.SDO_DIFFERENCE(a."GEOM", d."GEOM", 0.05) As "GEOM" FROM "TOTAL_PLOT" a, "ROAD" d
WHERE d."GID" = :new."GID";

INSERT INTO "USER_SDO_GEOM_METADATA" (TABLE_NAME, COLUMN_NAME, DIMINFO)
VALUES ('NEW_ROWS','GEOM',
        MDSYS.SDO_DIM_ARRAY(
          MDSYS.SDO_DIM_ELEMENT('X',140955.0,445546.0,0.001),
          MDSYS.SDO_DIM_ELEMENT('Y',34998.0,291800.0,0.001))
END;
/

0 个答案:

没有答案