[Zope-DB] Inserting into multiple tables

Dieter Maurer dieter at handshake.de
Wed May 5 17:13:50 EDT 2004

Bryce Harrington wrote at 2004-5-4 17:24 -0700:
>If I have a form that needs to insert into multiple tables on
>submission, how can this be done?
>Basically, I am creating an entry in a main table and then creating
>entries in several join tables.  During the insert into the main table a
>unique ID key is generated, and this key is used as an input to each of
>the other tables.

Your main problem is not a Zope problem but a database problem.
You must be able to access the generated unique ID.

Many databases support the concept "sequence" for this.
A "sequence" has methods "nextval" and "curval" (or similarly
named). If your database does this, your Z SQL Method
may look somehow like this:

    INSERT INTO ... (...) values (
    <dtml-sqlvar sql-delimiter>
    INSERT INTO ... (...) values (


More information about the Zope-DB mailing list