开发者

Missing Parenthesis

开发者 https://www.devze.com 2023-01-10 21:07 出处:网络
Here is the script I am running DROP SEQUENCE S_JobStatus; CREATE SEQUENCE S_JobStatus INCREMENT BY 1 START WITH 1

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 f开发者_开发知识库rom dual
    END;
Error report:
ORA-00906: missing left parenthesis
00906. 00000 -  "missing left parenthesis"
*Cause:    
*Action:

Where am I missing the parenthesis?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消