ASP.NET + Oracle Part3 のホームへ戻る

シーケンス・トリガー一覧

 

本サイトで使用する、シーケンス、トリガーを掲げます。

 

商品区分IDのシーケンス(Categories_CategoryID_Seq)

CREATE SEQUENCE Categories_CategoryID_Seq

  NOCYCLE NOORDER NOCACHE NOMAXVALUE MINVALUE 1

  INCREMENT BY 1 START WITH 9;

 

商品区分のトリガー(Categories_Tri)

CREATE OR REPLACE TRIGGER Categories_Tri

BEFORE INSERT ON Categories

FOR EACH ROW

BEGIN

  IF :new.CategoryID IS NULL THEN

    SELECT Categories_CategoryID_Seq.NEXTVAL

    INTO :new.CategoryID

    FROM DUAL;

  END IF;

END;

 

得意先IDのシーケンス(Customers_CustomerID_Seq)

CREATE SEQUENCE Customers_CustomerID_Seq

  NOCYCLE NOORDER NOCACHE NOMAXVALUE MINVALUE 1

  INCREMENT BY 1 START WITH 51;

 

得意先のトリガー(Customers_Tri)

CREATE OR REPLACE TRIGGER Customers_Tri

BEFORE INSERT ON Customers

FOR EACH ROW

BEGIN

  SELECT Customers_CustomerID_Seq.NEXTVAL

  INTO :new.CustomerID

  FROM DUAL;

END;

 

 

運送業者IDのシーケンス(Shippers_ShipperID_Seq)

CREATE SEQUENCE Shippers_ShipperID_Seq

  NOCYCLE NOORDER NOCACHE NOMAXVALUE MINVALUE 1

  INCREMENT BY 1 START WITH 4;

 

 

運送業者のトリガー(Shippers_Tri

CREATE OR REPLACE TRIGGER Shippers_Tri

BEFORE INSERT ON Shippers

FOR EACH ROW

BEGIN

  IF :new.ShipperID IS NULL THEN

    SELECT Shippers_ShipperID_Seq.NEXTVAL

    INTO :new.ShipperID

    FROM DUAL;

  END IF;

END;

 

 

ASP.NET + Oracle Part3 のホームへ戻る