[Zope-DB] Two actions in one ZSQL method = one transaction?
Ken Winter
ken at sunward.org
Wed Jun 13 21:11:08 EDT 2007
I have a question (stated in three different ways) about the following ZSQL
method:
1. Will it *always* return the person_id of the person that it just
inserted?
2. Will it do this even if another user inserted another person just in
between the two SQL actions in this ZSQL method?
3. In other words: Does a ZSQL method initiate a database transaction, so
that no other user can inset another record between the two actions in this
ZSQL method?
Here's the ZSQL method:
<dtml-comment>
title: Method to add a Person
and return the id of the Person just created
connection_id: dhatabase
arguments:
first_name
middle_names
last_name
</dtml-comment>
insert into person (first_name, middle_names, last_name)
values (
<dtml-sqlvar first_name type="string">,
<dtml-sqlvar middle_names type="string">,
<dtml-sqlvar last_name type="string">
);
select person_id from person where person_id = (select max(person_id) from
person);
~ TIA
~ Ken
More information about the Zope-DB
mailing list