trigger很常用,无论是在HANA还是在Oracle中
请直接看代码
代码语言:javascript复制 CREATE TABLE TARGET ( A INT);
CREATE TABLE SAMPLE ( A INT);
CREATE TRIGGER TEST_TRIGGER_WHILE_UPDATE
AFTER UPDATE ON TARGET
BEGIN
DECLARE found INT := 1;
DECLARE val INT := 1;
WHILE :found <> 0 DO
SELECT count(*) INTO found FROM sample WHERE a = :val;
IF :found = 0 THEN
INSERT INTO sample VALUES(:val);
END IF;
val := :val 1;
END WHILE;
END;