oracle触发器查询问题

发布于 2024-08-18 19:12:33 字数 367 浏览 3 评论 0原文

谁能告诉我这个查询有什么问题吗?

create trigger Test_trigger 
   before insert on Test for each row 
   begin select TestSequence.nextval into :new.id from dual; 
end;/

当我运行此查询时,出现以下错误:

第 1 行出现错误:PLS-00103:当预期出现以下情况之一时遇到符号“文件结束”:

;
符号“;”被替换为“文件结束”以继续。

我使用的是 Oracle 10g Express 版。

Can anyone please tell me what is wrong with this query?

create trigger Test_trigger 
   before insert on Test for each row 
   begin select TestSequence.nextval into :new.id from dual; 
end;/

When I run this query, I get the following error:

ERROR at line 1: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

;
The symbol ";" was substituted for "end-of-file" to continue.

I am using Oracle 10g Express Edition.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无所的.畏惧 2024-08-25 19:12:33

结尾的“/”是 SQL*Plus 语法。您可能正在使用 Oracle Apex 中的 SQL 工具 - 在这种情况下,请省略“/”。

The trailing "/" is SQL*Plus syntax. You're probably using the SQL tool in Oracle Apex - in which case, omit the "/".

尘世孤行 2024-08-25 19:12:33

如果你删除末尾的“/”,它应该可以工作。

It should work if you remove the "/" at the end.

浮云落日 2024-08-25 19:12:33

这是我尝试执行的脚本:

drop index TestTableIdx1;
drop index TestIdx1;
drop index TestIdx2;
drop table Test;
drop sequence TestSequence;
drop table TestTable; 

create table TestTable (
  objId      number        NOT NULL,
  type       varchar(16)   NOT NULL,
  title      varchar(192)          ,
  url        varchar(192)          ,
  primary key(objId, type)
);

create table Test (
  id         number        NOT NULL,
  objId      number        NOT NULL,
  type       varchar(16)   NOT NULL, 
  timeslot   timestamp     NOT NULL,
  contextId  number        ,
  pubId      number        NOT NULL,
  category   varchar(24),
  meta       varchar(32),
  pageviews  number        NOT NULL,
  aggrLevel  number        NOT NULL,
  primary key(id)
);

create table Dummy (
  id int NOT NULL,
  primary key(id)
);

create sequence TestSequence 
start with 1 
increment by 1 
nomaxvalue;

create trigger Test_trigger
before insert on Test
for each row
begin
select TestSequence.nextval into :new.id from dual;
end;
/

create index TestTableIdx1 on TestTable (
  objId desc, type asc
);

create index TestIdx1 on Test (
  timeslot desc, objId desc, type asc
);

create index TestIdx2 on Test (
  timeslot desc
);

create index TestIdx3 on Test (
  objId desc, type asc
);

create index TestIdx4 on Test (
  contextId desc
);

Here is the script I'm trying to execute:

drop index TestTableIdx1;
drop index TestIdx1;
drop index TestIdx2;
drop table Test;
drop sequence TestSequence;
drop table TestTable; 

create table TestTable (
  objId      number        NOT NULL,
  type       varchar(16)   NOT NULL,
  title      varchar(192)          ,
  url        varchar(192)          ,
  primary key(objId, type)
);

create table Test (
  id         number        NOT NULL,
  objId      number        NOT NULL,
  type       varchar(16)   NOT NULL, 
  timeslot   timestamp     NOT NULL,
  contextId  number        ,
  pubId      number        NOT NULL,
  category   varchar(24),
  meta       varchar(32),
  pageviews  number        NOT NULL,
  aggrLevel  number        NOT NULL,
  primary key(id)
);

create table Dummy (
  id int NOT NULL,
  primary key(id)
);

create sequence TestSequence 
start with 1 
increment by 1 
nomaxvalue;

create trigger Test_trigger
before insert on Test
for each row
begin
select TestSequence.nextval into :new.id from dual;
end;
/

create index TestTableIdx1 on TestTable (
  objId desc, type asc
);

create index TestIdx1 on Test (
  timeslot desc, objId desc, type asc
);

create index TestIdx2 on Test (
  timeslot desc
);

create index TestIdx3 on Test (
  objId desc, type asc
);

create index TestIdx4 on Test (
  contextId desc
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文