[Zope-DB] Are transactions/atomicity implicit in ZSQL+ Oracle ?
Wed, 20 Mar 2002 20:58:52 -0800
On Thursday 21 March 2002 03:06 am, firstname.lastname@example.org wrote:
> En r=E9ponse =E0 kapil thangavelu <email@example.com>:
> > > I need to make a ZSQL method that inserts data in a table this way:
> > > 1) first, generate a new ID with something like SELECT MAX(ID)+1 AS
> > my_id
> > > FROM ...
> > > 2) then, INSERT with the ID previously generated ( is INSERT INTO
> > > VALUES (<dtml-var my_id>.... the right way to do this ?)
> > it would be much better to use a sequence. the above is only safe in =
> > transaction serialized mode.
> Unfortunately I can't modify the db structure or even add simple object=
> My question is precisely this: is there explicit LOCKing to do to ensur=
> serialization or does Zope do it automatically for all SQL statements i=
> single ZSQL method?
zope doesn't do any locking per say, it tries to handle transaction=20
integration to make all methods invoked during a request happen=20
> > > Also (main question), is there something particular to do to ensure
> > > SELECT+INSERT is done in a single transaction, thus avoiding
> > concurrency
> > > problems ?
> > zope's integration with databases depends on whats supported by the
> > database
> > adapter. if the adapter supports transactions than zope will commit
> > transactions involving any changed persistent objects within zope and
> > the dbs
> > at the end of a request.
> By 'request' you mean http request ?
> If the Oracle DA supports transactions, which I guess it does, am I rig=
> to assume that the 2 SQL statements inside my ZSQL method are an atomic
> operation ?
you can assume transactionality. zope's transaction boundary is at the en=
an http request where it will attempt to commit to all db adapters involv=
during a request. which means all zsql methods involved in a http request=
associated with a single transaction. of course this is not true if you a=
manually manipulating the transaction.
atomicity, depends on what you're doing and how you've set up the databas=
connection/env, specifically its transaction isolation level. =20