Insert Oracle sequence

2

Error SQL Error: ORA-00911: Invalid character

  • 00000 - "invalid character"
  • * Cause: identifiers may not start with any ASCII character other than letters and numbers. $ # _ are also allowed after the first character. Identifiers enclosed by doublequotes may contain any character other than a doublequote. Alternative quotes (q '# ... #') can not use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual.

    CREATE TABLE CursoSequencia (
        cod_curso NUMBER(3),
        nome_curso VARCHAR2(30) NOT NULL,
        carga_hor NUMBER(3),
        CONSTRAINT cursoSquencia_cod_pk PRIMARY KEY(cod_curso)
    );
    
    CREATE SEQUENCE cod_curso INCREMENT BY 1
    START WITH 1001;
    
    INSERT INTO CursoSequencia VALUES(cod_curso.nextval, ‘AdministracaoOracle’,3);
    
    INSERT INTO CursoSequencia VALUES(cod_curso.nextval, ‘AdministracaoSQLServer’,3);
    
        
    asked by anonymous 25.05.2017 / 00:17

    2 answers

    0

    If you have created a sequence that will auto increment, at the time of inserting, you do not need to enter the id, the database will automatically add.

    So just do your insert this way:

    INSERT INTO CursoSequencia (nome_curso, carga_hor) VALUES (‘AdministracaoSQLServer’,3);

        
    25.05.2017 / 01:24
    -1

    Pass the version of the bank that is trying to run the DML command, from version 12c the bank has the auto increment.

    Another point is that older versions of the database (such as 10g) do not allow pseudocolumns (sequence.nextval) directly in DML commands, you need to start in a variable to insert it into a PL / SQL block. link [document_oracle_apontando_drug_command_rescription]

        
    30.05.2017 / 13:13