Solved

ADO corrupts date time values in where clause

Posted on 2006-11-14
6
658 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
  • 3
  • 2
6 Comments
 
LVL 142

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 142

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now