缺少括号

发布于 2024-09-13 12:24:58 字数 1203 浏览 2 评论 0原文

这是我正在运行的脚本

DROP SEQUENCE S_JobStatus;

CREATE SEQUENCE S_JobStatus
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE 
    NOMINVALUE 
;
-- 
-- TABLE: JobStatus 
--

DROP TABLE JobStatus;
CREATE TABLE JobStatus(
    Id             NUMBER(10, 0)    NOT NULL,
    ShortName      NUMBER(10, 0)    NOT NULL,
    Description    NUMBER(10, 0)    NOT NULL,
    CONSTRAINT PK_JobStatus PRIMARY KEY (Id)
)
;
/* DROP TRIGGER JobStatus_SequenceTrigger; */
CREATE TRIGGER JobStatus_SequenceTrigger
BEFORE INSERT
ON JobStatus
    FOR EACH ROW
    WHEN new.Id IS NULL
    BEGIN
        SELECT S_JobStatus.nextval into :new.Id from dual
    END;

这是 Oracle SQL Developer 中的输出

DROP SEQUENCE S_JobStatus succeeded.
CREATE SEQUENCE succeeded.
DROP TABLE JobStatus succeeded.
CREATE TABLE succeeded.

Error starting at line 22 in command:
CREATE TRIGGER JobStatus_SequenceTrigger
BEFORE INSERT
ON JobStatus
    FOR EACH ROW
    WHEN new.Id IS NULL
    BEGIN
        SELECT S_JobStatus.nextval into :new.Id from dual
    END;
Error report:
ORA-00906: missing left parenthesis
00906. 00000 -  "missing left parenthesis"
*Cause:    
*Action:

我在哪里缺少括号?

Here is the script I am running

DROP SEQUENCE S_JobStatus;

CREATE SEQUENCE S_JobStatus
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE 
    NOMINVALUE 
;
-- 
-- TABLE: JobStatus 
--

DROP TABLE JobStatus;
CREATE TABLE JobStatus(
    Id             NUMBER(10, 0)    NOT NULL,
    ShortName      NUMBER(10, 0)    NOT NULL,
    Description    NUMBER(10, 0)    NOT NULL,
    CONSTRAINT PK_JobStatus PRIMARY KEY (Id)
)
;
/* DROP TRIGGER JobStatus_SequenceTrigger; */
CREATE TRIGGER JobStatus_SequenceTrigger
BEFORE INSERT
ON JobStatus
    FOR EACH ROW
    WHEN new.Id IS NULL
    BEGIN
        SELECT S_JobStatus.nextval into :new.Id from dual
    END;

Here is the output in Oracle SQL Developer

DROP SEQUENCE S_JobStatus succeeded.
CREATE SEQUENCE succeeded.
DROP TABLE JobStatus succeeded.
CREATE TABLE succeeded.

Error starting at line 22 in command:
CREATE TRIGGER JobStatus_SequenceTrigger
BEFORE INSERT
ON JobStatus
    FOR EACH ROW
    WHEN new.Id IS NULL
    BEGIN
        SELECT S_JobStatus.nextval into :new.Id from dual
    END;
Error report:
ORA-00906: missing left parenthesis
00906. 00000 -  "missing left parenthesis"
*Cause:    
*Action:

Where am I missing the parenthesis?

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

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

发布评论

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

评论(1

过期以后 2024-09-20 12:24:58

我认为你的触发条件需要括号。

WHEN (new.Id IS NULL)

创建触发器语法:

http://download.oracle。 com/docs/cd/B12037_01/server.101/b10759/statements_7004.htm

I think that your trigger condition needs parentheses.

WHEN (new.Id IS NULL)

Create trigger syntax:

http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_7004.htm

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