Home » Developer & Programmer » Precompilers, OCI & OCCI » When will BatchSQLException be raised?
When will BatchSQLException be raised? [message #175687] Sun, 04 June 2006 18:51 Go to next message
Messages: 1
Registered: June 2006
Junior Member
Under what circumstances will a BatchSQLException be raised? What type of error needs to be thrown in a SQL statement (within a batch of statements) to cause this exception to be thrown by the OCCI library?

I have been successfull in using calls to Statement::setMaxIterations(), Statement::addIteration() and Statement::executeUpdate() to send multiple statements to the database in a single network trip. The SQL being called is a stored procedure taking 3 IN parameters. All is going well for the case of a succesfull SQL statement.

But I want to be able to handle the case where not all statements are successful. For example, if I send 20 statements in a single batch and one fails, I want to handle the error as best as possible. Even if I have to roll back all statements, it would be nice to know which specific statement within the batch failed.

The OCCI documentation suggests a call to Statement::setBatchErrorMode(true) followed by a catch block catching BatchSQLException objects seems to do the trick. However, in my unit testing, I don't seem to be able to force such an exception.

In short, what sort of error do I need to force in my SQL code so that a BatchSQLException will be raised?

I have tried raising an exception in the SQL code but that seems to skip the BatchSQLException exception handler and go straight to the following SQLException handler. Is there some PL/SQL code that I need to place in my stored procedure?

Thanks in advance.
Re: When will BatchSQLException be raised? [message #189591 is a reply to message #175687] Fri, 25 August 2006 03:16 Go to previous message
Messages: 28
Registered: July 2005
Junior Member
Try a batch insert of rows into a table with a unique key constraint on a column. Try to insert duplicate rows and you will see this exception, using which you can find out which row insert has problems.
Previous Topic: some problems of occi9 (code)
Next Topic: Significant Digits
Goto Forum:

Current Time: Thu Sep 16 14:48:20 CDT 2021