Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ADO corrupts date time values in where clause

Posted on 2006-11-14
6
Medium Priority
?
666 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 900 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 600 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

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!

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

886 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