Oracle Dates through Data Provider - ORA-01858

From: Paul Long <paul_a_long_at_hotmail.com>
Date: 29 Jun 2004 13:46:54 -0700
Message-ID: <4c46b5c8.0406291246.6309341a_at_posting.google.com>



Hi,

I'm having a nightmare when trying to insert records into an Oracle database that contain dates. I've believe I should be using the to_date() function but I continually get the error:

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

I'm reading from a text file and the datetime values are as follows:

12-DEC-2003 12:01:22
12-DEC-2003 12:01:23
12-DEC-2003 12:01:24
12-DEC-2003 12:01:25

If I carry out straight forward SQL upon the database I can insert records without any problems. E.g.:

INSERT INTO MyTable (Name, OccurrenceTime) VALUES ('Test', to_date('31-Dec-2004 10:47:50', 'DD-MON-YYYY HH:MI:SS') );

However, my problem is achieving the same results from my C# application that uses the DataTable structure and OracleDataAdapter object.

The DataTable's Rows.List[0] contains:

 ItemArray[0] = "Test"
 ItemArray[1] = "to_date('31-DEC-2004 10:47:50', 'DD-MON-YYYY HH:MI:SS')"

However, when I call the Update() method of OracleDataAdapter and pass the DataTable as the parameter I get the ORA-01858 error.

Can I pass: 'to_date(....)' via the DataTable? It appears from what I've found on the newsgroups that you cannot pass a literal date straight into Oracle.

Please, if anyone can help, I would very much appreciate it.

Regards,

Paul. Received on Tue Jun 29 2004 - 22:46:54 CEST

Original text of this message