Page 1 of 1

Handling errors in DML Array loading.

Posted: Thu 22 Feb 2007 15:27
by MarkF
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

Posted: Fri 23 Feb 2007 10:04
by Plash
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.

Posted: Fri 23 Feb 2007 13:25
by MarkF
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!

Posted: Fri 23 Feb 2007 16:29
by MarkF
In TOCICommand.InternalExecute you are raising any error before setting RowsProcessed. Please change this to fill RowsProcessed regardless of any errors.

Thanks

Posted: Mon 26 Feb 2007 10:00
by Plash
Thank you for your assistance. We'll add these changes in the next ODAC build.

Posted: Mon 26 Feb 2007 12:11
by MarkF
Fantastic! Thanks!