Link to home
Start Free TrialLog in
Avatar of sathyagiri
sathyagiriFlag for United States of America

asked on

ADO corrupts date time values in where clause

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.






ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sathyagiri

ASKER

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.

does the primary key use all the 10 columns? Bad implementation.
does the date field be a date field or a timestamp data type?

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.
>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 ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial