Pergunta

I'm doing an insert from a C# .NET app into an Oracle database. The query that is failing looks something like:

INSERT INTO staging (create_date) VALUES ('16-Nov-1999')

When I run it from SQL Navigator, it runs fine. Through .NET, the database throws:

ORA-01858: a non-numeric character was found where a numeric was expected

I ran a few test cases and confirmed that it's the year causing the exception. Anything after '31-Dec-1999' runs fine.

Foi útil?

Solução

Better to use the TO_DATE function when submitting values that are to be stored as DATEs:

INSERT INTO staging 
   (create_date) 
VALUES 
   (TO_DATE('16-Nov-1999', 'DD-MON-YYYY'))

Outras dicas

The issue is with using the generic System.Data.OleDB provider. The Oracle specific System.Data.OracleClient does not have this issue.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top