--建立油箱標定表GasDemarcateide
/*drop table GasDemarcate;
drop Sequence SEQ_GasDemarcate_ID;
drop TRIGGER Trig_Update_GasDemarcate_ID;
drop TRIGGER Trig_ProPri_GasDemarcate_ID;it
select from GasDemarcate
insert into GasDemarcate(GASSIZEID)
values(15);
commit;
delete GasDemarcate/table
/==============================================================/
/ Table: "GasDemarcate" /
/==============================================================/
create table GasDemarcate
(
ID INTEGER not null,
GASSIZEID INTEGER,
OILVALUE FLOAT,
SENSORVAL FLOAT,
constraint PK_GASDEMARCATE_ID primary key (ID)
);class
comment on column GasDemarcate.ID is
'主鍵自增加ID';date
comment on column GasDemarcate.GASSIZEID is
'對應GASSIZE表的ID';select
comment on column GasDemarcate.OILVALUE is
'油量';im
comment on column GasDemarcate.SENSORVAL is
'測量值(傳感器值)';next
--建序列
CREATE SEQUENCE SEQ_GasDemarcate_ID
INCREMENT BY 1
START WITH 1
MAXVALUE 1.0E28 MINVALUE 1 NOCYCLE
CACHE 50 NOORDER;tab
--建自動更新的觸發器
CREATE OR REPLACE TRIGGER Trig_Update_GasDemarcate_ID
BEFORE INSERT
ON GasDemarcate
FOR EACH ROW
DECLARE
next_id NUMBER;
BEGIN
--Get the next id number from the sequence
SELECT SEQ_GasDemarcate_ID.NEXTVAL
INTO next_id
FROM dual;
--Use the sequence number as the primary key
--for the record being inserted.
:new.id := next_id;
END;di
--要選中下面的單獨執行!!!!!!!
--建保護 PRIMARY KEY 的觸發器CREATE OR REPLACE TRIGGER Trig_ProPri_GasDemarcate_IDBEFORE UPDATE OF ID ON GasDemarcateFOR EACH ROWBEGINRAISE_APPLICATION_ERROR (-20000,'Trig_ProPri_GasDemarcate_ID : Updates of the ID field'|| 'are not allowed. ');END;