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
精彩评论