Re: [cx-oracle-users] insert/update/delete returning state
Brought to you by:
atuining
From: Jose S. <jos...@sf...> - 2013-03-13 13:45:34
|
It works :) thanks a lot, Amaury. j On 03/13/2013 01:27 PM, Amaury Forgeot d'Arc wrote: > Hi, > > 2013/3/12 Jose Soares <jos...@al... > <mailto:jos...@al...>> > > Hi all, > > I'm trying to returning UPDATE/INSERT/DELETE state. > > Is there a way to know the state of an UPDATE, for example, > if it fails or success, like in the following example? > > import cx_Oracle > DBURI = "sfa/5Y@16.3:1521/em" > connection = cx_Oracle.connect(DBURI) > cursor = connection.cursor() > success = cursor.execute("UPDATE TEST set id=17 where id=16") > print success > > > There are two kinds of "successes": > > - the first one is when the statement was executed without error. > In case of failure, an exception will be raised. > > - the other one is when the statement actually updated something. > For this you can look at "cursor.rowcount", this contains the number > of updated rows. > In your case, it will probably be zero or one. > > Hope this helps, > -- > Amaury Forgeot d'Arc > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar > > > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |