随笔 - 589  文章 - 0 评论 - 116 trackbacks - 5

HANA 创建Triggers语法:

CREATE TRIGGER <trigger_name> <trigger_action_time> <trigger_event> ON <subject_table_name> [REFERENCING <transition_list>] [<for_each_row>] BEGIN [<trigger_decl_list>] [<proc_handler_list>] <trigger_stmt_list> END

例子:

 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;

 

触发器

image

posted on 2013-04-09 16:39  沧海-重庆  阅读(1810)  评论(0编辑  收藏