Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Handling AttrValException and throwing proper error message in UI

970108Jul 29 2013 — edited Jul 29 2013

Hi All,

I have a scenario where I need to validate each attribute of a row before I push it into the DB. Validation of the attribute is majorly checking if the value is null or not. If null I am raising a AttrValException. However because of the BundleException property, it doesn't throw the exception onto the UI directly/immediately but it gets bundled up into RowValException and then into a TxnValException.  After inserting the row, I have other data which is processed and validated in similar fashion. I am using OperationBinding to invoke the method which inserts the rows. However, when I use OpeationBinding.getErrors() post execute, it doesn't pick up the TxnValException and proceeds further and tries to commit the data(I am using EL {binding.commit.execute} for commit action).

Here are my doubts relating to this

     1) Why isn't OperationBinding.getErrors picking up the TxnValException?

     2) If OperationBinding.getErrors doesn't work, what is an alternative to handle this case and check if the exception was thrown or not?

     3).When commit runs and sees that the remaining data is exception free, then will it try to commit the valid data and ignore the invalid data or will it throw an exception as some data is corrupt?

     4) In case there are multiple attributes which fail the validation, though there is only 1 TxnValException, after iterating through it recursively we can get all AttrValExceptions. How can I throw all the AttrValExceptions simultaneously? Or rather how can I get the error message to display all the AttrValExceptions raised?

Comments

390020
Works ok in my environment (note I'm using python 2.5).

-----
$ ipython
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
Type "copyright", "credits" or "license" for more information.

In [1]: import cx_Oracle as ora

In [2]: con_str = "i/me@mine"

In [3]: con = ora.connect(con_str)

In [4]: type(con)
Out[4]: <type 'cx_Oracle.Connection'>

In [5]: con = ora.Connection(con_str)

In [6]: type(con)
Out[6]: <type 'cx_Oracle.Connection'>
-----
Q: what is the output if you do:

type(connection_string)


?

675949
type(connection)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'connection' is not defined
390020
I asked for connection_string, not connection. Also I'm assuming you're running it in the same python session you run the previous code you show us. Is that right?
675949
Here is the code.....

Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import cx_Oracle
connection_string = "system/mypass@GLOBAL"
connection = cx_Oracle.Connection(connection_string)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-24315: illegal attribute type
type(connection_string)
<type 'str'>
>>>




I am doing all this under the same python session.
390020
Since I was unable to find out what is happening, I forwarded your problem to the cx-oracle-users list. You can find an answer over there. Here's [the link|http://sourceforge.net/mailarchive/forum.php?forum_name=cx-oracle-users&max_rows=25&style=nested&viewmonth=200812&viewday=19].
730306
I encountered this problem today, and there was no answer on the web.
This is what I learned, although it is embarassing to admit. I had installed
the Ora11g version of cx_Oracle, but the database is Ora10g. I deleted
the Ora11g cx_Oracle files, installed the Ora10g version, and everything
worked.
&nbsp;&nbsp;&nbsp;&nbsp;--dang
1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 26 2013
Added on Jul 29 2013
3 comments
460 views