I tried to make primary key for table Staff automatically sequenced.
input:
CREATE SEQUENCE staff_idseq START WITH 1 INCREMENT BY 1 MAXVALUE 9999;
CREATE TABLE Staff
(
staffid number(4) not null primary key,
name varchar2(21) not null unique,
permission varchar2(10) not null
);
CREATE OR REPLACE TRIGGER staff_idtrig
BEFORE INSERT ON Staff
FOR EACH ROW WHEN (new.staffid is null)
BEGIN
SELECT staff_idseq.nextval INTO :new.staffid FROM dual;
END;
but when I load this, after creating sequence and table, it requests me to input more command as if I forgot to add semicolon on end of line. Maybe there are some error on my query, but I cannot find what mistake was I made, because I failed to get out from input prompt without using Ctrl+c.
staffid number(4) generated as identityor set a sequence as a default value.