Solved

ADO corrupts date time values in where clause

Posted on 2006-11-14
6
664 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

617 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