DROP SEQUENCE AutoIncrement;
DROP TRIGGER PROFILE_TRIGGER;
CREATE TABLE PROFILE
(
ID NUMBER PRIMARY KEY,
PROFILENAME VARCHAR2(25),
FONT VARCHAR2(25),
DEFAULT_PADDING NUMBER,
FONT_SIZE NUMBER
);
CREATE SEQUENCE AUTOINCREMENT
start with 1
increment by 1
nomaxvalue;
CREATE TRIGGER PROFILE_TRIGGER
BEFORE INSERT
ON PROFILE
REFERENCING NEW AS NEW
FOR EACH ROW BEGIN
SELECT AUTOINCREMENT.nextval INTO :NEW.ID FROM dual;
END;
INSERT INTO PROFILE(PROFILENAME) VALUES('some value one');
INSERT INTO PROFILE(PROFILENAME) VALUES('some value two');
SELECT * FROM PROFILE;
No comments:
Post a Comment