[Zope] Z Sql method newbie question

J. Cone jcone@g8labs.com
Mon, 16 Jul 2001 10:35:10 +0100


Hello,

I don't know about Interbase; something like this should work in Oracle,
although I haven't used multiple SQL statements in a Z SQL Method yet, I
just know it's documented as being possible.  On your database, this may
even interlock correctly with itself without explicit locking.

lock table <table> in exclusive mode;
insert into <table> (id, name, surname)
  select nvl(max(id),0)+1, <sqlvar ...>, <sqlvar ...>
  from <table>

The lock table ... is about coping when several of these are run
simultaneously.

The nvl(...) is about replacing the NULL value when there are no rows with
a sensible value.

Regards,
J. Cone

At 22:55 14/07/01 +0200, Fabrizio wrote:
>Hallo,
>
>Newbie. Zope 2.3.3 on Win98. Interbase 6.0 through gvibDA.
>
>I have a database table with three fields : id, name, surname.
>I want to create a simple Z Sql method that adds a new record to the table
>and automatically assigns an increased id value to the new record .

<snip>