문제

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.

도움이 되었습니까?

해결책

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'))

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top