Solved

ADO corrupts date time values in where clause

Posted on 2006-11-14
6
662 Views
Last Modified: 2009-07-29
We have an application that uses ADO for talking to an Oracle database. We use ORaoledb.oracle as the provider.

At times we are getting error messages like "Row cannot be located for updating" and sometime ORA-01841 Invalid date.

This error does not happen to all the users. But once it starts occuring for a user, it's persistent till the time user logs out and logs back into the application.

We were able to do an oracle trace and identify the sql statements that were causing this.

In some cases we see that the year component of a date field in the where clause being chopped off. This happens only in fields where date is 30-DEC-1899.
(ie) instead of passing 1899-12-30 09:30:00 it passes -12-30 09:30:00. This throws the invalid date format error.

Also in some cases the time component seems to be offset by 10 secs (ie) In the database if the time component of a date field is 00:00:00, ado passes 00:00:10 in the where clause. Thus causing the unable to locate row error.

Now all these are in the where clause.Since the where clause is something that ADO builds, we are at a loss as to what's going on.

The values for the same fields (used in the set protion of the update) passed from the application are in correct format.

Any ideas or thoughts welcome.






0
Comment
Question by:sathyagiri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 17940391
do you have a primary key defined on the table?
from experience, that error you seem to have is exactly what I had...


now, regarding the time issue: 30-DEC-1899
you might be better of setting that value to NULL instead of the minimum date, or hardcoding that value in the sql statement instead of passing that value



0
 
LVL 14

Author Comment

by:sathyagiri
ID: 17940501
Yes we do have a primary key on the table. However looking at the update statement that ADO generates it uses all the columns in the where clause.

(ie) If my table has 10 columns

where clause will have where col1= prev value and col2 =prev value etc..

This is the part where the date truncation and time offset is happening.

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17944898
does the primary key use all the 10 columns? Bad implementation.
does the date field be a date field or a timestamp data type?

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 14

Author Comment

by:sathyagiri
ID: 17946803
No the primary key is on just one field. But however when ADO generates the sql for update it uses all the fields in the table in the where clause.

THe date field is of datatype date.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17949507
>No the primary key is on just one field. But however when ADO generates the sql for update it uses all the fields in the table in the where clause.
how do you open the recordset?
you should open it with adOpenkeyset ...
0
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 200 total points
ID: 17953857
best would be to transform your date into a string in your frontend,
and then using the TO_DATE function with a Mask in your where clause

meikl ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fill Null values 5 55
Oracle mutateing errors 3 27
return value based on substr 10 73
Oracle Join issue. 3 48
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question