[DB-SIG] Transaction with DCOracle?

Peter Sabaini sabaini@niil.at
Mon, 22 Jan 2001 18:37:35 +0100 (CET)


i do something like

----------------
from DCOracle import Connect, error
try: cursor.somedangerous_sql()
except error, detail: cursor.rollback()
----------------

hth

peter.

On Mon, 22 Jan 2001, [euc-kr] ¹æ¹Î wrote:

:Dear python geeks..
:
:-----------------------------------------------------------
:import DCOracle
:csor = DCOracle.Connect('...')
:try:
:    csor.execute('INSERT INTO history VALUES(\'20010114\', 123123)')
:
:    csor.execute('INSERT INTO history VALUES(\'20010114\', 123123)')
:
:    csor.commit()
:    print 'commit'
:except Exception:
:    csor.rollback()
:    print 'rollback'
:csor.close()
:-----------------------------------------------------------
:
:I've tried to handle Exceptions to get transaction like that,
:but I couldn't roll back the sqls.
:
:you know, if the first column in HISTORY table is a primary key,
:the 2nd row couldn't be inserted.
:
:and then i hope python throws exception, rolls back so
:the 1st row is not inserted.
:
:here's the error msg.
:
:--------------------------------------------------------------------
:Traceback (innermost last):
:  File "test.py", line 9, in ?
:    csor.execute('INSERT INTO history VALUES(\'20010114\', 123123)')
:  File "/usr/lib/python1.5/DCOracle/ociCurs.py", line 299, in execute
:    r = self._execute(params__, kw)
:  File "/usr/lib/python1.5/DCOracle/ociCurs.py", line 260, in _execute
:    if rc!=3129: self._error()
:  File "/usr/lib/python1.5/DCOracle/ociCurs.py", line 109, in _error
:    raise error, (rc, oci_.OracleErrorMessage(self._c.lda, rc))
:oci.error: (1, 'ORA-00001: unique constraint (POINT.PK_PN_HISTORY)
:violated')
:--------------------------------------------------------------------
:
:do i have to handle another exception?
:
:thank you in advance.
:
:Min.
:

-- 

_________________________________________________
peter sabaini, mailto: sabaini@niil.at
-------------------------------------------------