[Zope-DB] Compound SQL Statements

Dieter Maurer dieter at handshake.de
Fri Jul 9 13:33:51 EDT 2004


Roy S. Rapoport wrote at 2004-6-29 16:23 -0700:
>I'm using Zope 2.7.0 with ZMySQLDA 2.0.9 and Python-MySQL 1.1.1.
> ...
>INSERT INTO person
>(Login, Password, FirstName, LastName, Email, Organization, Title, Street1,
>Street2, City, State, Postal, Country)
>VALUES(
> ...
>);
>
>SELECT LAST_INSERT_ID()
>---
> 
>Within a ZSQL statement nets me:
>Error, _mysql_exceptions.ProgrammingError: (1064, "You have an error in
>your SQL syntax. Check the manual that corresponds to your MySQL server
>version for the right syntax to use near ';\n\nSELECT LAST_INSERT_ID()' at
>line 18") 
>
>Even though this seems like perfectly legit SQL code (and it works within a
>mysql interpreter).

Your database thinks differently...

Depending on the database backend, you may not be able to
separate different SQL commands with ";" (even though your
interactive SQL shell may allow it).

You can use "<dtml-var sql-delimiter>" as separator.
In this case, Zope's DA will separate the individual SQL commands
and send them separately to the database.

-- 
Dieter


More information about the Zope-DB mailing list