When I try to compile the following Oracle code:
CREATE TABLE authors (
id NUMBER PRIMARY KEY, /* what if two authors have the same name! */
name VARCHAR2(200) NOT NULL
);
/* autoinrement sequence */
CREATE SEQUENCE authors_id_seq START WITH 1 INCREMENT BY 1;
/* trigger run before every insert into authors table - copies MySQL autoincrement */
CREATE TRIGGER authors_insert_trg BEFORE INSERT ON authors
FOR EACH ROW WHEN (new.id IS NULL)
BEGIN
SELECT authors_id_seq.nextval INTO :new.id FROM FUAL;
END;
It says:
table AUTHORS created.
sequence AUTHORS_ID_SEQ created.
TRIGGER authors_insert_trg compiled
Warning: execution completed with warning
I cannot see any error. Could somebody please help me out?
Typo:
FROM FUALshould beFROM DUAL