Handling errors in DML Array loading.

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Handling errors in DML Array loading.

Post by MarkF » Thu 22 Feb 2007 15:27

If I'm loading a dml array of 5 records and record 3 has an error, an exception is thrown and 2 records have been loaded into the database. It looks like both RowsProcessed and RowsAffected are zero in this case but probably should be 2? How can errors be handled (i.e. reported and either continue or abort) without knowing which record caused the error and how many records worked? Or am I missing something?

By the way, my old db component set had an event "OnArrayError" which would report the error line number and allow you to continue or stop. That would be a nice improvement to TOraSQL!

Thanks for any help!

-Mark Ford

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 23 Feb 2007 10:04

You can use the TOraLoader component to load records with error handling. Set the LoadMode property of the TOraLoader to lmDML to use DML array loading or lmDirect to use direct path loading. This component has the OnError event where row number is passed and you can select an action to perform.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Fri 23 Feb 2007 13:25

The docs for TOraLoader say:

Write OnError event handler to process errors that occur during loading. Handler is used only if LoadMode = lmDirect, i.e. when using Oracle Direct Path interface.

I've checked using the loader demo with DML and a bad record and it never fires the onError handler.

The main problem that I have is TOraSQL not correctly reporting RowsProcessed (or RowsAffected.) Can this be fixed? As I'm sure you understand, not knowing how many records made it into the database is a pretty big issue.

Thanks for any help!

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Fri 23 Feb 2007 16:29

In TOCICommand.InternalExecute you are raising any error before setting RowsProcessed. Please change this to fill RowsProcessed regardless of any errors.

Thanks

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 26 Feb 2007 10:00

Thank you for your assistance. We'll add these changes in the next ODAC build.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Mon 26 Feb 2007 12:11

Fantastic! Thanks!

Post Reply