oracle创建自动增长列出错 Warning: Trigger created with compilation errors
createsequenceQM_ORDER_SECRETARY_Sstartwith1incrementby1nomaxvalue;createorreplacetri...
create sequence QM_ORDER_SECRETARY_S start with 1 increment by 1 nomaxvalue;
create or replace trigger QM_ORDER_SECRETARY_T
before insert on QM_ORDER_SECRETARY
referencing NEW AS n
for each row
declare
begin
select QM_ORDER_SECRETARY_S into :n.ORDER_SECRETARYfrom dual;
end; 展开
create or replace trigger QM_ORDER_SECRETARY_T
before insert on QM_ORDER_SECRETARY
referencing NEW AS n
for each row
declare
begin
select QM_ORDER_SECRETARY_S into :n.ORDER_SECRETARYfrom dual;
end; 展开
5个回答
展开全部
SQL> CREATE OR REPLACE TRIGGER BeforeTestCreate2Insert
2 BEFORE INSERT ON test_create_tab2
3 FOR EACH ROW
4 BEGIN
5 SELECT test_sequence2.nextval INTO :new.id FROM dual;
6 END;
7 /
Trigger created.
上面这个是一个编译通过的, 能够正常运行的例子.
你那里 的 declare 后面,没有定义任何变量, 可以去掉.
还有
select QM_ORDER_SECRETARY_S
要修改为 select QM_ORDER_SECRETARY_S.nextval
还有
n.ORDER_SECRETARYfrom dual
不知道是不是排版的问题, 应该是
n.ORDER_SECRETARY from dual
也就是 n.ORDER_SECRETARY 和 from 之间,应该有一个空格.
2 BEFORE INSERT ON test_create_tab2
3 FOR EACH ROW
4 BEGIN
5 SELECT test_sequence2.nextval INTO :new.id FROM dual;
6 END;
7 /
Trigger created.
上面这个是一个编译通过的, 能够正常运行的例子.
你那里 的 declare 后面,没有定义任何变量, 可以去掉.
还有
select QM_ORDER_SECRETARY_S
要修改为 select QM_ORDER_SECRETARY_S.nextval
还有
n.ORDER_SECRETARYfrom dual
不知道是不是排版的问题, 应该是
n.ORDER_SECRETARY from dual
也就是 n.ORDER_SECRETARY 和 from 之间,应该有一个空格.
展开全部
create sequence QM_ORDER_SECRETARY_S start with 1 increment by 1 nomaxvalue;
create or replace trigger QM_ORDER_SECRETARY_T
before insert on QM_ORDER_SECRETARY
for each row
begin
select QM_ORDER_SECRETARY_S.Nextval into :New.ORDER_SECRETARY from dual;
end;
create or replace trigger QM_ORDER_SECRETARY_T
before insert on QM_ORDER_SECRETARY
for each row
begin
select QM_ORDER_SECRETARY_S.Nextval into :New.ORDER_SECRETARY from dual;
end;
更多追问追答
追问
像你这样我也试过了 ,还是会出现这个错误
追答
什么错误,没问题的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
create or replace trigger QM_ORDER_SECRETARY_T
before insert on QM_ORDER_SECRETARY
for each row
declare
s_id number;
begin
select QM_ORDER_SECRETARY_S.nextval into s_id from dual;
:new.ORDER_SECRETARY:=s_id;
end QM_ORDER_SECRETARY_T;
before insert on QM_ORDER_SECRETARY
for each row
declare
s_id number;
begin
select QM_ORDER_SECRETARY_S.nextval into s_id from dual;
:new.ORDER_SECRETARY:=s_id;
end QM_ORDER_SECRETARY_T;
更多追问追答
追问
用你的办法试了,也是Warning: Trigger created with compilation errors;
追答
你检查下表中的ORDER_SECRETARY列是number的么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select QM_ORDER_SECRETARY_S.NEXTVAL into :n.ORDER_SECRETARYfrom dual;
晕,都是2011-7-8 10:57,为什么我第二啊
晕,都是2011-7-8 10:57,为什么我第二啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
为什么一定要用sql语句创建啊 。你不能手工创建。。。
追问
我是刚用oracle ,不知道怎么手工操作创建
追答
在数据库下的 sequence 文件夹 右击 添加
里面有 开始值,最大值,递增值。你看看。我好久不用oracle了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询