create table FRAME_RES_PHOTO ( ID NUMBER(8) not null, RESURI VARCHAR2(64) not null, RESTYPE VARCHAR2(8) not null, FILENAME VARCHAR2(128) not null, PHOTO CLOB not null, PSIZE NUMBER(8), PHOTOTYPE VARCHAR2(8) not null, PHOTOEXT VARCHAR2(8) not null, SORTNO NUMBER(8) not null, DESCRIPTION VARCHAR2(256), CREATORID VARCHAR2(64) not null, CREATEDATE DATE not null, EXP_FIELD1 VARCHAR2(64) ); create sequence SEQ_FRAME_RES_PHOTO minvalue 1 maxvalue 999999999999999999999999999 start with 1 increment by 1 nocache; create or replace trigger tri_frame_res_photo before insert on frame_res_photo for each row declare -- local variables here v_num number; begin select Seq_Frame_Res_Photo.Nextval INTO V_NUM FROM DUAL; :NEW.ID:=V_NUM; end tri_frame_res_photo; sequence配合trigger
create sequence SEQ_OFFICE_SUPPLIES_APPLY minvalue 1 maxvalue 999999999999999999999999999 start with 1 increment by 1 nocache;create or replace trigger tri_OFFICE_SUPPLIES_APPLY before insert on OFFICE_SUPPLIES_APPLY for each row declare -- local variables here v_num number; begin select SEQ_OFFICE_SUPPLIES_APPLY.Nextval INTO V_NUM FROM DUAL; :NEW.ID:=V_NUM; end tri_OFFICE_SUPPLIES_APPLY INVALID我的这个sql有问题吗?为什么建的触发器是无效(status:INVALID )的呢
create or replace trigger tri_OFFICE_SUPPLIES_APPLY before insert on OFFICE_SUPPLIES_APPLY for each row declare -- local variables here v_num number; begin select SEQ_OFFICE_SUPPLIES_APPLY.Nextval INTO V_NUM FROM DUAL; :NEW.ID:=V_NUM; end tri_OFFICE_SUPPLIES_APPLY; --少了分号
(
ID NUMBER(8) not null,
RESURI VARCHAR2(64) not null,
RESTYPE VARCHAR2(8) not null,
FILENAME VARCHAR2(128) not null,
PHOTO CLOB not null,
PSIZE NUMBER(8),
PHOTOTYPE VARCHAR2(8) not null,
PHOTOEXT VARCHAR2(8) not null,
SORTNO NUMBER(8) not null,
DESCRIPTION VARCHAR2(256),
CREATORID VARCHAR2(64) not null,
CREATEDATE DATE not null,
EXP_FIELD1 VARCHAR2(64)
);
create sequence SEQ_FRAME_RES_PHOTO
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;
create or replace trigger tri_frame_res_photo
before insert on frame_res_photo
for each row
declare
-- local variables here
v_num number;
begin
select Seq_Frame_Res_Photo.Nextval INTO V_NUM FROM DUAL;
:NEW.ID:=V_NUM;
end tri_frame_res_photo;
sequence配合trigger
NEW是指什么?是FRAME_RES_PHOTO这个表吗?可以用表名代替吗?
如minitoy给你的例子
old是Oracle触发器里的一个关键字,代表旧的数据,比如对于delete触发器,old关键字在MSSQL中相当于 deleted表
建议多了解Oracle触发器相关资料
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;create or replace trigger tri_OFFICE_SUPPLIES_APPLY
before insert on OFFICE_SUPPLIES_APPLY
for each row
declare
-- local variables here
v_num number;
begin
select SEQ_OFFICE_SUPPLIES_APPLY.Nextval INTO V_NUM FROM DUAL;
:NEW.ID:=V_NUM;
end tri_OFFICE_SUPPLIES_APPLY
INVALID我的这个sql有问题吗?为什么建的触发器是无效(status:INVALID )的呢
create or replace trigger tri_OFFICE_SUPPLIES_APPLY
before insert on OFFICE_SUPPLIES_APPLY
for each row
declare
-- local variables here
v_num number;
begin
select SEQ_OFFICE_SUPPLIES_APPLY.Nextval INTO V_NUM FROM DUAL;
:NEW.ID:=V_NUM;
end tri_OFFICE_SUPPLIES_APPLY; --少了分号