[Zope-DB] DCOracle2 - executemany does not return rowcount on exception

Gary Aviv gary.aviv at intec.us
Thu Feb 26 09:04:35 EST 2004


Thank you for a great module. 

I am using Python 2.3, Oracle 8i, DCOracle2 1.3 beta 

My issue is with executemany. In particular, I attempted to insert
7 rows unto a table. Here is script excerpt.

-------------------------------------
List = [
        ('1', 'abc', DCOracle2.Date(2004, 2, 1),20023.15),
        ('2', 'abc', DCOracle2.Date(2004, 2, 1),12323.12),
        ('3', 'abc', DCOracle2.Date(2004, 2, 1),5423344.06),
        ('4', 'abc', DCOracle2.Date(2004, 2, 1),20344302.90),
        ('5', 'abc', DCOracle2.Date(2004, 2, 1),4534534.54),
        ('6', 'abc', DCOracle2.Date(2004, 2, 1),768786.76),
        ('7', 'abc', DCOracle2.Date(2004, 2, 1),124.01)
]

sql = """INSERT INTO gary_test (prod_id, cust_id, time_id, amount)
    VALUES (:1, :2, :3, :4)"""

cursor = dbc.prepare(sql)

try:
        x = cursor.executemany(sql, List )
except DCOracle2.DatabaseError, e:
        print str(e)
-------------------------------------

Since the table has a unique primary key, we get:

(1, 'ORA-00001: unique constraint (IAT_LOOKUP.SYS_C003795) violated')

Now the issue is to discover which row actually had the error.
I tried cursor.rowcount but it is -1.

Next I tried:

R = cursor.fetchone()         

which yielded a Segmentation fault. The fault occurs
in the routine Cursor_ResultSet when it calls
PyList_Size

        for (i = 1; i <= PyList_Size(self->definition); i++) {
                mode = OCI_DEFAULT;
                        ...
                }
       
because self->definition is NULL.

What is the correct way to find out which row had the error.

Thank you,

Gary.Aviv at intec.us





More information about the Zope-DB mailing list