Problem inserting records in Oracle

2

I'm having trouble inserting records into Oracle, below is the insert I use:

insert into COMPRAS (id, valor, data, observacoes, recebido)
values (id_seq.nextval, 200, '19-FEB-2008', 'MATERIAL ESCOLAR', '1');

However, it generated this SQL error;

   
 Erro ao iniciar na linha 1 no comando  
    insert into COMPRAS (id, valor, data, observacoes, recebido)  
    values (id_seq.nextval, 200, '19-FEB-2008', 'MATERIAL ESCOLAR', '1')  
    Relatório de erro:  
    Erro de SQL: ORA-01858: foi localizado um caractere não numérico onde se esperava um numérico  
    01858. 00000 -  "a non-numeric character was found where a numeric was expected"  
    *Cause:    The input data to be converted using a date format model was  
               incorrect.  The input data did not contain a number where            
               anumber was required by the format model.    
    *Action:   Fix the input data or the date format model to make sure the  
               elements match in number and type.  Then retry the operation.

My table looks like this:

COMPRAS

Nome        Nulo     Tipo         
----------- -------- ------------ 
ID          NOT NULL NUMBER       
VALOR                NUMBER       
DATA                 DATE         
OBSERVACOES          VARCHAR2(30) 
RECEBIDO             CHAR(1)      

The table was thus created:

create table compras (
    id number primary key,
    valor number, 
    data date, 
    observacao varchar2(30),
    recebido char check (recebido in(0,1)));

    CREATE SEQUENCE ID_SEQ;

How do I resolve this?

    
asked by anonymous 17.01.2016 / 11:23

1 answer

1

You're trying to insert a VARCHAR into a DATE convert date using TO_DATE as per Eduardo Almeida's comment

TO_DATE('19-Feb-2008', 'DD-Mon-YYYY')
    
02.06.2016 / 21:47