首页 > 数据库技术 > 详细

oracle的分号和斜杠/

时间:2015-06-17 09:21:45      阅读:218      评论:0      收藏:0      [点我收藏+]

;是执行语句必须的
/是执行语句块必须的

比如执行一个触发器

CREATE OR REPLACE TRIGGER "TRG_1" BEFORE INSERT ON "CATEGORY" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW ENABLE
DECLARE 
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
  IF INSERTING AND :new.catid IS NULL THEN
    SELECT  catid_seq.NEXTVAL INTO v_newVal FROM DUAL;
    IF v_newVal = 1 THEN 
      SELECT NVL(max(catid),0) INTO v_newVal FROM category;
      v_newVal := v_newVal + 1;
      LOOP
           EXIT WHEN v_incval>=v_newVal;
           SELECT catid_seq.nextval INTO v_incval FROM dual;
      END LOOP;
    END IF;
   :new.catid := v_newVal;
  END IF;
END;
/
CREATE OR REPLACE TRIGGER "TRG_1" BEFORE INSERT ON "CATEGORY" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW ENABLE
DECLARE 
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
  IF INSERTING AND :new.catid IS NULL THEN
    SELECT  catid_seq.NEXTVAL INTO v_newVal FROM DUAL;
    IF v_newVal = 1 THEN 
      SELECT NVL(max(catid),0) INTO v_newVal FROM category;
      v_newVal := v_newVal + 1;
      LOOP
           EXIT WHEN v_incval>=v_newVal;
           SELECT catid_seq.nextval INTO v_incval FROM dual;
      END LOOP;
    END IF;
   :new.catid := v_newVal;
  END IF;
END;
/

oracle的分号和斜杠/

原文:http://www.cnblogs.com/songzhenghe/p/4582319.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!