Results 1 to 3 of 3

Thread: Auto_increment

  1. #1
    Join Date
    Aug 2003
    Location
    Vicenza(I)
    Posts
    21

    Unanswered: Auto_increment

    Hello my name is Elisa and I have a problem with this line of code:
    CREATE TABLE Film
    (IdFilm int not null auto_increment PRIMARY KEY,
    Titolo VARCHAR2(20) NOT NULL,
    Regista VARCHAR2(20) NOT NULL,
    Personaggi_Principali VARCHAR2(50) NOT NULL,
    Personaggi_Secondari VARCHAR2(50) NOT NULL,
    Nazione VARCHAR2(20) NOT NULL,
    Durata NUMBER(3) NOT NULL,
    Genere VARCHAR2(10) NOT NULL,
    Trama VARCHAR2(500) NOT NULL,
    Critica VARCHAR2(10) NOT NULL,
    Locandina VARCHAR2(20) NOT NULL,
    Note VARCHAR2(100) NOT NULL)
    when I execute the result is:
    Error: ORA-00922: missing or invalid option.
    It's very urgent.
    Thank you Elisa

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Exclamation

    auto_increment does not exist in Oracle!

    You have to create a sequence:

    CREATE SEQUENCE FILM_SEQ;

    and then you can either use it during the insert as in:

    INSERT INTO Film VALUES (FILM_SEQ.NEXTVAL, ...);

    or create a trigger:

    CREATE OR REPLACE TRIGGER BI_FILM_TRG
    BEFORE INSERT ON FILM FOR EACH ROW
    BEGIN
    SELECT FILM_SEQ.NEXTVAL INTO :NEW.IdFilm FROM DUAL;
    END;
    /
    NOTE: DO NOT USE IT ON BOTH THE INSERT AND TRIGGER!!!


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Aug 2003
    Location
    Vicenza(I)
    Posts
    21

    Talking Thank you

    Thank you very much for your help
    Elisa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •